#include <iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int k = 10;
		int x = 0, y = 0;
		int i;
		bool flag = true;
		while (k--)
		{
			cin >> i;
			if (i > y) y = i;
			else if (i > x) x = i;
			else flag = false;
		}
		if (flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}
