#include<iostream>
using namespace std;
int main(){
    int n;cin>>n;
    while(n--){
        int b=0,c;cin>>c;
        for(int i=1;i<=9;i++){
            int t;cin>>t;
            if(c<t)c=t;
            else if(b<t)b=t;
            else {c=0;break;}
        }
        cout<<(c?"YES":"NO")<<endl;
    }
    return 0;
}
