#include <bits/stdc++.h>
using namespace std;

int main() {
  int n; cin >> n;
  while (n--) {
    vector<int> a(10); for (int i = 0; i < 10; ++i) cin >> a[i];
    stack<int, deque<int>> s0({a[0]}), s1({0});
    for (int i = 1; i < 10; ++i) {
      int m = 10, mpos = -1;
      if (s0.top() < a[i]) {
        if (a[i] - s0.top() < m) {
          m = a[i] - s0.top();
          mpos = 0;
        }
      }
      if (s1.top() < a[i]) {
        if (a[i] - s1.top() < m) {
          m = a[i] - s1.top();
          mpos = 1;
        }
      }
      if (mpos == -1) {
        cout << "NO" << endl;
        break;
      }
      ( (mpos) ? s1 : s0 ).push(a[i]);
      if (i == 9) cout << "YES" << endl;
    }
  }
  return 0;
}

