#include<iostream>
#include<vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  for(int i=0;i<n;i++) {
    int a=0;
    int b=0;
    bool failed = false;
    for(int i=0;i<10;i++) {
      int n;
      cin >> n;
      if(failed) {
        continue;
      }

      if(b <= a && a < n) {
        // cout << "1 " << a << ":" << b << ":" << n << endl;
        a = n;
      } else if (a < b && b < n) {
        // cout << "2 " << a << ":" << b << ":" << n << endl;
        b = n;
      } else if (b <= a && b < n) {
        // cout << "3 " << a << ":" << b << ":" << n << endl;
        b = n;
      } else if (a < b && a < n) {
        // cout << "4 " << a << ":" << b << ":" << n << endl;
        a = n;
      } else {
        // cout << "x " << a << ":" << b << ":" << n << endl;
        cout<<"NO"<<endl;
        failed = true;
        continue;
      }
      if(i==9) {
        cout<<"YES"<<endl;
      }
    }
  }
  return 0;
}
