#include <iostream>
using namespace std;
int b, c, cnt, x[11];
void dfs(int i){
   if(x[i] > b){
       b = x[i];
       dfs(i+1);
       cnt++;
   }
   if(x[i] > c){
       c = x[i];
       dfs(i+1);
       cnt++;
   }
}

int main(void){
   int N;
   cin >> N;
   while(N != 0){
       b = 0;
       c = 0;
       cnt = 0;
       for(int i = 0; i < 10; i++){
           cin >> x[i];    
       }
       dfs(0);
       if(cnt == 11)   cout << "YES" << endl;
       else    cout << "NO" << endl;
       N--;
   }
   return 0;
}
