#include <iostream>
using namespace std;

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

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

			a = x - hole[0];
			b = x - hole[1];
			if (a < 0 && b < 0) {
				cout << "NO";
				break;
			}

			if (a < 0) {
				hole[1] = x;
			}
			else if (b < 0) {
				hole[0] = x;
			}else if (a < b) {
				hole[0] = x;
			}else {
				hole[1] = x;
			}

			if (j == 9) {
				cout << "YES";
			}
		}
		cout << endl;
	}
	return 0;
}