#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  int b[5];
  int c[5];

  int n;
  cin >> n;
  while(n--){

    int a[10];
    int j = 0;
    int k = 0;
    for( int i = 0 ; i < 10 ; i++ ){
      cin >> a[i];
      if( i % 2 == 0 ){
	b[j++] = a[i];
      }
      if( i % 2 == 1 ){
	c[k++] = a[i];
      }
    }
    int cnt_b = 0;
    int cnt_c = 0;
    for( int i = 0 ; i < 4 ; i++ ){
      if( b[i] < b[i+1] )cnt_b++;
      if( c[i] < c[i+1] )cnt_c++;
    }
    if( cnt_b == 4 && cnt_c == 4 ) cout << "YES" << endl;
    else cout << "NO" << endl; 
  }
 return 0;
}