#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,m;
int a[25];
int ans1[25];
int ans2[25];
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        memset(a,0,sizeof(a));
        memset(ans1,0,sizeof(ans1));
        memset(ans2,0,sizeof(ans2));
        for(int i=1;i<=10;i++)
        {
            scanf("%d",&a[i]);
        }
        ans1[1]=a[1];
        ans2[0]=0;
        int p1=0,p2=0;
        int i;
        for(i=2;i<=10;i++)
        {
            if(a[i]>ans1[p1])
            {
                ans1[++p1]=a[i];
            }else if(a[i]>ans2[p2]){
                ans2[++p2]=a[i];
            }else{
                printf("NO\n");
                break;
            }
        }
        if(i>10)
        {
            printf("YES\n");
        }
    }
    return 0;
}
