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

int main() {
	int n, x;
	cin >> n;

	for (int i = 0; i++ < n;) {
		int hole[2] = { 0 };
		string judge = "YES";
		for (int j = 0; j < 10; j++) {
			cin >> x;

			if (hole[0] < x) {
				hole[0] = x;
			}else if (hole[1] < x) {
				hole[1] = x;
			} else {
				judge = "NO";
				break;
			}
		}
		cout << judge << endl;
	}
	return 0;
}