#include <iostream>

int main() {
	int n;
	for (std::cin >> n; n > 0; --n) {
		int a = 0, b = 0;
		bool f = true;
		for (int i = 0; i < 10; ++i) {
			int x; std::cin >> x;
			if (x > a) { a = x; }
			else if (x > b) { b = x; }
			else { f = false; }
		}
		std::cout << (f ? "YES" : "NO") << std::endl;
	}
	return 0;
}