#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,a;
  int b = 11,c = 11;
  cin >> n;
  while(n--){
    for(int i = 0;i < 10;i++){
      cin >> a;
      if(b > a)b = a;
      else if(c > a)c = a;
      else {
	cout << "NO" << endl;
	return 0;
      }  
    }
    cout << "YES" << endl;
  }
  return 0;
}