#include <iostream>
using namespace std;

int main(){
  int N,t,B,C;
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    B = C = 0;
    for(int j = 0; j < 10; j++){
      cin >> t;
      if(B >= t && C >= t){
	cout << "NO" << endl;
	break;
      }
      else if(B < t && C < t){
	if(B < C) C = t;
	else B = t;
      }
      else if(B < t) B = t;
      else if(C < t) C = t;
      //      cout << B << " ";
      if(j == 9) cout << "YES" << endl;
    }
  }
  return 0;
}