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

int main() {
    int N; 
    cin >> N;

    for(int i = 0; i < N; i++) {
        bool ans = true;
        int B_top = 0, C_top = 0;
        vector<int> ball(10);
        for(int i = 0; i < 10; i++) {
            cin >> ball[i];
        }
        for(int j = 0; j < 10; j++) {
            if(B_top < ball[j]) {
                B_top = ball[j];
            }
            else if(C_top < ball[j]) {
                C_top = ball[j];
            }
            else {
                ans = false;
                break;
            }
        }
        if(ans) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl; 
        }
    }
    return 0;
}
