#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>

int N;
int M = 10;
int **inData;
int *lTube;
int *rTube;

bool dfs(int n, int i, int l, int r)
{
	if (i==M)
		return true;

	//left tube
	if (l==-1 || inData[n][i]>lTube[l]) {
		lTube[l+1] = inData[n][i];
		if (dfs(n, i+1, l+1, r)) return true;
	}

	//right tube
	if (r==-1 || inData[n][i]>rTube[r]) {
		rTube[r+1] = inData[n][i];
		if (dfs(n, i+1, l, r+1)) return true;
	}

	//failed
	return false;
}

int main()
{
	int n, i, j;

	while (1) {

		//input & allocate memory
		if (scanf("%d ", &N) == EOF) break;

		inData = (int **)calloc(N, sizeof(int *));
		for (i=0; i<N; i++) {
			inData[i] = (int *)calloc(M, sizeof(int));
			
			for (j=0; j<M; j++)
				scanf("%d ", &(inData[i][j]));
		}

		lTube = (int *)calloc(M, sizeof(int));
		rTube = (int *)calloc(M, sizeof(int));

		for (n=0; n<N; n++) {
			for (i=0; i<M; i++)
				lTube[i] = rTube[i] = 0;

			//dfs & output
			if (dfs(n, 0, -1, -1))
				printf("YES\n");
			else
				printf("NO\n");
/*			
			printf("Left:\n");
			for (i=0; i<M; i++)
				printf("%d ", lTube[i]);
			puts("");
			printf("Right:\n");
			for (i=0; i<M; i++)
				printf("%d ", rTube[i]);
			puts("");
			printf("------------------\n");
*/
		}
/*
		for (i=0; i<N; i++) {
			for (j=0; j<M; j++)
				printf("%d ", inData[i][j]);
			puts("");
		}
*/
		//free memory
		for (i=0; i<N; i++)
			free(inData[i]);
		free(inData);
		free(lTube);
		free(rTube);
	}

	return 0;
}