#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> b;
		vector<int> c;

		for (int i = 0; i < 10; i++)
		{
			int x;
			cin >> x;

			if (i == 0)
			{
				b.push_back(x);
			}
			else if (i == 1)
			{
				c.push_back(x);
			}
			else
			{
				if (x > b.back() || x > c.back())
				{
					if (b.back() > c.back())
					{
						b.push_back(x);
					}
					else
					{
						c.push_back(x);
					}
				}
			}
		}

		cout << (b.size() + c.size() == 10 ? "YES" : "NO") << endl;
	}
}
