#include <iostream>

using namespace std;

int main()
{
	int N, A[10], C = 1;

	cin >> N;

	for (int p = 0; p < N; p++)
	{
		cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4] >> A[5] >> A[6] >> A[7] >> A[8] >> A[9];

		for (int i = 0; i < 10; i++)
		{
			if (A[i] == C)
			{
				C++;
			}
		}

		for (int i = 0; i < 10; i++)
		{
			if (A[i] == C)
			{
				C++;
			}
		}

		if (C == 11)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

		C = 1;
	}

	return 0;
}