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

int main() {
	int a, n, j;
	cin >> n;
	for (int i = 0; i < n; i++) {
		vector<int> a(10);
		vector<int> b, c;
		for (j = 0; j < 10; ++j) cin >> a[j];
		for (j = 0; j < 11; j++) {
			if (j == 10) {
				break;
			}
			if (j == 0) {
				b.push_back(a[j]);
			}
			else if (a[j] < b[b.size() - 1] && c.size() == 0) {
				c.push_back(a[j]);
			}
			else if (a[j] > b[b.size() - 1]) {
				b.push_back(a[j]);
			}
			else if (a[j] > c[c.size() - 1]) {
				c.push_back(a[j]);
			}
			else {
				break;
			}
		}
		if (j == 10) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}