#include<stdio.h>

int main()
{
	int loop,right,left,data;
	int i,j;
	scanf("%d",&loop);
	while(loop-->0)
	{
		right=left=j=0;
		for(i=0;i<10;i++)
		{
			scanf("%d",&data);
			if(data>right)
				right=data;
			else if(data>left)
				left=data;
			else
				j=1;
		}
		if(j==1)
			printf("NO\n");
		else
			printf("YES\n");
	}
}