#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int a[10];

bool dfs(int i, vector<int>& l, vector<int>& r) {
  if (i == 10) return true;
  bool res = false;
  if (l.empty() || l.back() < a[i]) {
    l.emplace_back(a[i]);
    res |= dfs(i + 1, l, r);
    l.pop_back();
  }
  if (r.empty() || r.back() < a[i]) {
    r.emplace_back(a[i]);
    res |= dfs(i + 1, l, r);
    r.pop_back();
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> a[j];
    }
    vector<int> l, r;
    cout << (dfs(0, l, r) ? "YES" : "NO") << endl;
  }

  return 0;
}
