#include <iostream>
using namespace std;


int main()
{
	int n;
	cin >> n;
	int a[11],min_a=0, min_b=0;
	bool flag=true;
	while (n--)
	{
		for (int i = 0; i < 10; i++)
			cin >> a[i];
		for (int j = 0; j < 10; j++)
		{
			if (a[j] >= min_a)
			{
				min_a = a[j];
			}
			else if (a[j] >= min_b)
			{
				min_b = a[j];
			}
			else
			{
				flag = false;
			}
		}
		if (flag==true)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
    return 0;
}