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

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int t;
    cin>>t;
    while(t--){
        int ball[10];
        for(int i=0;i<10;i++){
            cin>>ball[i];
        }

        int left=0;
        int right=0;

        bool ok=true;
        bool direction=true;
        while(ok){
            for(int i=0;i<10;i++){
                if(direction){
					
                    if(ball[i]>left){
                        left=ball[i];
                        direction=!direction;
                    }
					
                    else{
                        ok=false;
                        break;
                    }
                }

                else{

                    if(ball[i]>right){
                        right=ball[i];
                        direction=!direction;
                    }

                    else{
                        ok=false;
                        break;
                    }
                }
            }
            break;
        }

        if(ok) cout<<"YES";
        else cout<<"NO";
        if(t) cout<<endl;
    }

    return 0;
}