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

int n;
int a[10];


bool dfs(int i, int r, int l) {
    if (i == 9) return a[i] > r || a[i] > l;
    if ( dfs(i+1, a[i+1], l)) return true;
    if ( dfs(i+1, r, a[i+1])) return true;
    return false;
}

void solve() {
    if (dfs(0,a[0],a[0])) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> a[j];
        }
        solve();
    }
}
