#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<string>
using namespace std;

static int N;
static vector<int> balls;
static vector<int> A, B;
static bool flag;

void dfs(int id)
{
	if (flag) return;
	if (id >= 10)
	{
		flag = true;
		return;
	}
	//printf("%d\n", id);
	if ((A.size() > 0 && balls[id] > A.back()) || A.size() == 0)
	{
		A.push_back(balls[id]);
		dfs(id + 1);
	}
	else if ((B.size() > 0 && balls[id] > B.back()) || B.size() == 0)
	{
		B.push_back(balls[id]);
		dfs(id + 1);
	}
	
}




int main()
{
	while (scanf("%d", &N) != EOF)
	{
		while (N--)
		{
			balls.clear();
			balls.resize(10);
			for (int i = 0; i < 10; i++) scanf("%d", &balls[i]);
			A.clear();
			B.clear();
			flag = false;
			dfs(0);
			printf(flag ? "YES\n" : "NO\n");
		}
	}
	return 0;
}
