#include <cstdio>
#include <vector>
using namespace std;
int A[10];
vector<int> B, C;
int N;

void solve() {
  B.clear();
  C.clear();
  for (int i = 0; i < 10; i++) {
    int k = A[i];
    if (B.empty()) {
      B.push_back(k);
      continue;
    }
    if (C.empty()) {
      C.push_back(k);
      continue;
    }
    int m = max(k - B.back(), k - C.back());
    if (m < 0) {
      printf("NO\n");
      return;
    }
    if (m == k - B.back())
      C.push_back(k);
    else
      B.push_back(k);
  }
  printf("YES\n");
}

int main() {
  scanf("%d", &N);
  while (N--) {
    for (int i = 0; i < 10; i++) scanf("%d", &A[i]);
    solve();
  }
}
