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

    


