#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<bool>l;
	int o[10], n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++)cin >> o[j];
		int sum = o[0], num = 0;
		for (int k = 1; k < 10; k++) {
			if (o[k] < sum) {
				num++;
			}
			sum = max(sum, o[k]);
		}
		l.push_back(!(num >= 2));
	}
	for (bool b : l) {
		if (b)cout << "YES";
		else cout << "NO";
		cout << endl;
	}
	char c;
	cin >> c;
}