#include <iostream>

using namespace std;

int main()
{
	int input[10];
	int i = 0, num, j;
	int count = 0, flag = 0;

	cin >> num;

	while ( i < num )
	{
		for ( j = 0 ; j < 10 ; j = j + 1 )
		{
			cin >> input[j];
			if ( j >= 1 )
			{
				if ( input[j - 1] > input[j] )
					count = count + 1;
				else if ( input[j - 1] < input[j] )
					count = 0;

				if ( count == 2 )
				{
					flag = 1;
					break;
				}
			}

		}
		
		if ( flag == 0 )
			cout << "YES" << endl;
		else if ( flag == 1 )
			cout << "NO" << endl;

		flag = 0;
		count = 0;
		i = i + 1;
	}

	return 0;
}