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

int balls[20];
int R, L;

bool dfs(int n) {
  if (n == 10) {
    return true;
  }
  if (R < balls[n]) {
    R = balls[n];
    if (dfs(n+1)) {
      return true;
    }
  }
  if (L < balls[n]) {
    L = balls[n];
    if (dfs(n+1)) {
      return true;
    }
  }
  return false;
}

int main(void) {
  int N;
  cin >> N;
  while (N--) {
    for (int i = 0; i < 10; i++) {
      cin >> balls[i];
    }
    R = balls[0];
    L = 0;

    if (dfs(1)) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}