#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <stack>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

void solve33() {
    stack<int> st1;
    stack<int> st2;
    REP(i,10) {
        int j;
        cin >> j;
        if (st1.size() == 0 || st1.top() < j) st1.push(j);
        else if (st2.size() == 0 || st2.top() < j) st2.push(j);
        else break;
        if (i == 9) {cout << "YES" << endl; return;}
    }
    cout << "NO" << endl;
}

int main() {
    int n;
    cin >> n;
    REP(i,n) {
        solve33();
    }
    return 0;
}