#include<iostream>
#include<algorithm>
int N;
int t[10000][10];
bool d[10000];
int a, b, c;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			std::cin >> t[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 10; j++) {
			if (t[i][j] > a) {
				a = t[i][j];
			}
			else if (t[i][j] > b) {
				b = t[i][j];
			}
			else {
				std::cout << "NO" << "\n";
				a = 0; b = 0;
				break;
			}
			if (j == 9) {
				std::cout << "YES" << "\n";
			}
		}
	}
	return 0;
}