#include <iostream>
using namespace std;

int main(){
  int n;
  
  cin >> n;
  for(int j = 0 ; j < n ; j++){ 

    int ball[10]={0},left[5]={0},right[5]={0};
    int lmax=0,rmax=0,lcnt=0,rcnt=0,lc=0,rc=0;
    
    for( int i = 0 ; i < 10 ; i++ ){
      cin >> ball[i];
      
      if(i % 2 == 0) left[lc++] = ball[i];
      else right[rc++] = ball[i];
      
      if( lmax < left[lc-1] ){
	lmax = left[lc-1];
	lcnt++;
      }   
      
      if( rmax < right[rc-1] ){
	rmax = right[rc-1];
	rcnt++;
      }
     
    }
    if( lcnt == 5 && rcnt == 5 ) cout << "YES" << endl;
    else cout << "NO" << endl;
  } 
  return 0;
}