#include<cstdio>


int num[10];
int m;

int main() {
	scanf("%d\n", &m);
	bool flag = true;
	while(m--)
	{ 
	    int l = 0;
	    int r = 0;
		flag = true;
		for (int i = 0; i < 10; i++)
			scanf("%d", &num[i]);
		for (int i = 0; i < 10; i++)
		{
			if (num[i] > l)
				l = num[i];
			else if (num[i] > r)
				r = num[i];
			else
			{
				flag = false;
				break;
			}
		}
		if (flag)
			printf("YES\n");
		else
			printf("NO\n");
	}


	return 0;
}
