#include<stdio.h>
int main(void)
{
	int n, i, j;
	int ball[10], blast = 0, clast = 0, min = 11, m = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 10; j++)
		{
			scanf("%d" , &ball[j]);
		}
		blast = ball[0];
		for (j = 1; j < 10; j++)
		{
			if (blast < ball[j])
				blast = ball[j];
			else if (clast < ball[j])
				clast = ball[j];
			else
			{
				m = 1;
				break;
			}
		}
		if (m == 1)
		{
			printf("NO\n");
			m = 0;
		}
		else
		{
			printf("YES\n");
		}

	}
	return 0;
}