#include <iostream>
using namespace std;
int b, c, cnt;
bool dfs(int x){
    if(x > b){
        b = x;
        return 1;
    }
    if(x > c){
        c = x;
        return 1;
    }
    return 0;
}

int main(void){
    int N, x;
    cin >> N;
    while(N != 0){
        b = 0;
        c = 0;
        cnt = 0;
        for(int i = 0; i < 10; i++){
            cin >> x;
            cnt += dfs(x);
        }
        if(cnt == 10)   cout << "YES" << endl;
        else    cout << "NO" << endl;
        N--;
    }
    return 0;
}

    


