#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  while(n--) {
    int s=0,t=0;
    int i;
    for (i=0;i<10;i++) {
      int a;
      cin >> a;
      if (a>s)
        s=a;
      else if (a>t)
        t=a;
      else
        break;
    }
    if (i==10)
      cout << "YES" << endl;
    else
      cout <<"NO" <<endl;
  }
}