#include<cstdio>

int a = 0,b = 0;
int flag = 0;
int suji[11] = {0};

void saiki(int cnt);

using namespace std;
int main(void)
{
	int kaisu;
	scanf("%d",&kaisu);
	for(int i = 0;i<kaisu;i++)
	{
		for(int j = 0;j<10;j++) scanf("%d",&suji[j]);
		saiki(0);
		if(flag == 1)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
		flag = 0;
		a = 0;
		b = 0;
	}
	return 0;
}

void saiki(int cnt)
{
	if(cnt == 10)
	{
		flag = 1;
		return;

	}

	if(a < suji[cnt])
	{
		a = suji[cnt];
		saiki(cnt+1);
	}
	if(b < suji[cnt])
	{
		b = suji[cnt];
		saiki(cnt+1);
	}


}