#include <iostream>
#include <vector>
using namespace std;
vector<int> A = {-1};
vector<int> B = {-1};
int num[10];
bool flag = false;
void push(int i)
{
	if (i == 10)
		flag = true;
	else
	{
		if (A.back() < num[i])
		{
			A.push_back(num[i]);
			push(i + 1);
			A.pop_back();
		}
		if (B.back() < num[i])
		{
			B.push_back(num[i]);
			push(i + 1);
			B.pop_back();
		}
	}
}
int main()
{
	int k;
	cin >> k;
	while (k--)
	{
		flag = false;
		for (int i = 0; i <= 9; ++i)
			cin >> num[i];
		if (flag == true)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}