#include<iostream>

using namespace std;

int main()
{
	int n, i,j,a, b, c,flag;

	cin >> n;
	for (i = 0; i < n; i++) {
		b = c = 0;
		flag = 1;
		for (j = 0; j < 10; j++) {
			cin >> a;
			if (a > b) {
				b = a;
			}
			else if (a > c) {
				c = a;
			}else {
				flag = 0;
			}
		}

		if (flag == 1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}
