#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int test[51];
signed main() {
    int n, a, b; cin >> n;
    for (int h = 0; h < n; h++) {
        int sum = 0, num = 0, c = 0;
        for (int i = 0; i < 10; i++) {
            cin >> a;
            if (c == 0) {
                if (sum < a) { sum = a; }
                else if (num < a) { num = a; }
                else { cout << "NO" << endl; c++; }
            }
        }
        if (c == 0) { cout << "YES" << endl; }
    }
}
