include<cstdio>
include<iostream>
sing namespace std;
nt main()

   int T;
   scanf("%d",&T);
   while(T--)
   {
       int n1=0,n2=0,x,jd;
       for(int i=1;i<=10;++i)
       {
           scanf("%d",&x);
           if(x>n1){n1=x;continue;}
           if(x>n2){n2=x;continue;}
           jd=1;
       }
       if(jd) puts("NO");
       else   puts("YES");
   }
