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

int main(){
    stack <int> st1;
    stack <int> st2;
    int n,tmp,a,b;
    bool judge;
    cin >> n;
    while(n--){
        judge = true;
        for(int i=0;i<10;i++){
            cin >> tmp;
            if(i == 0){
                st1.push(tmp);
                continue;
            }
            if(st2.empty()){
                if(tmp < st1.top()) st2.push(tmp);
                else st1.push(tmp);
                continue;
            }
            if(tmp - st1.top() > 0 && tmp - st2.top() > 0){
                a = tmp - st1.top();
                b = tmp - st2.top();
                if(a < b) st1.push(tmp);
                else st2.push(tmp);
            }
            else if(tmp - st1.top() > 0) st1.push(tmp);
            else if(tmp - st2.top() > 0) st2.push(tmp);
            else judge = false;
        }
        if(judge) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}