#include<cstdio> #include<iostream> #include<stack> using namespace std;   stack<int> B; stack<int> C;   int A[10];   int solve(){     for(int i = 0;i<10;i++){         if(!B.empty()){             if(B.top()<A[i]){                 B.push(A[i]);             }else if(C.top()<A[i] || C.empty()){                 C.push(A[i]);             }else{                 return 0;             }         }else{             B.push(A[i]);             //cout<<B.top()<<endl;         }     }     return 1; }    int init(){     while(!B.empty())         B.pop();     while(!C.empty())         C.pop();     B.push(-1);     C.push(-1);  }    int main(void){     int n;     cin>>n;     for(int j = 0;j<n;j++){     init();     for(int i = 0;i<10;i++){         cin>>A[i];     }     if(solve()){         cout<<"YES"<<endl;     }else{         cout<<"NO"<<endl;     }     }     return 0; } 