#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int t; cin >> t;
    while(t--) {
        vector<int> ball(10, 0);
        for(int i = 0; i < 10; ++i) cin >> ball.at(i);
        priority_queue<int> aque;
        priority_queue<int> bque;
        bool flg2 = true;
        for(int i = 0; i < 10; ++i) {
            bool flg = false;
            if(!aque.empty()) {
                if(aque.top() <= ball.at(i)) {
                    aque.push(ball.at(i));
                    flg = true;
                }
            }else {
                aque.push(ball.at(i));
                flg = true;
            }
            if(!flg) {
                if(!bque.empty()) {
                    if(bque.top() <= ball.at(i)) {
                        bque.push(ball.at(i));
                        flg = true;
                    }
                }else {
                    bque.push(ball.at(i));
                    flg = true;
                }
            }
            if(!flg) {
                flg2 = false;
                break;
            }
        }
        if(flg2) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}
