#include <iostream>
using namespace std;
int main (){
       int N,a[20]={0},b[20]={0},t;
       int ac=0,bc=0;
       cin>>N;
       for(int j=0;j<N;j++){
       for(int i=0;i<10;i++){
              cin>>t;
              if(a[ac]<t){
                 a[ac+1]=t;
                 ac++;
               }
               else if(b[bc]<t){
                  b[bc+1]=t;
                  bc++;
                }
                else break;
           }
           if(ac+bc==10){
                 cout<<"YES"<<endl;
            }
           else cout<<"NO"<<endl;
           }
return 0;
}