#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n;
	for (cin >> n; n--;)
	{
		vector<int> a(10);
		for (int i = 0; i < 10; i++)
		{
			cin >> a.at(i);
		}
		
		int id = 1;
		bool b = true;
		for (int i = 0; i < a.size() - 1; i++)
		{
			for (int j = 1; j < a.size() - 1; j++)
			{
				if (a.at(j) > a.at(j - 1))
				{
					continue;
				}
				else
				{
					if (id == a.at(j))
					{
						id++;
						a.erase(a.begin() + j);
						break;
					}
					else
					{
						b = false;
						break;
					}
				}
			}

			if (!b)
			{
				break;
			}
		}


		cout << (b ? "YES" : "NO") << endl;
	}
}
