#include <iostream>
using namespace std;

int ball[10];

int  bunbetu(int i, int left, int right) {
	if (i == 10) {
		cout << "YES" << "\n";
		return 0;
	}
	if (ball[i] < left) {
		if (ball[i] < right) {
			cout << "NO" << "\n";
			return 0;
		}
		bunbetu(i + 1, left, ball[i]);
	}
	else bunbetu(i + 1, ball[i], right);
}

int main() {
	int set;
	cin >> set;
	for (int i = 0; i < set; i++) {
		for (int j = 0; j < 10; j++){
			cin >> ball[j];
		}
		bunbetu(0, 0, 0);
	}
	return 0;
}