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

int main() {
	int n;
	int a;
	vector<int>d;
	vector<int>va;
	vector<int>vb;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> a;
			d.push_back(a);
		}
		va.push_back(d[0]);		

		for (int j = 1; j < 10; j++) {
			int b = va.size();
			int c = vb.size();

			if (d[j] > va[b-1]) {
				va.push_back(d[j]);
			}
			else if (d[j] > vb[c-1]) {
				vb.push_back(d[j]);
			}
			else {
				cout << "NO" << endl; 
				goto FINLOOP;
			}
		}
		cout << "YES" << endl;
			FINLOOP:
		;
	}
	return 0;
}