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

const int max_v = 10;
vector<int> l;
vector<int> r;

void solve(int N) {
	int k = 0, a = 0, flag = 0;
	while (k < N) {
		for (int i = 0; i < 10; i++) {
			cin >> a;
			if (l.empty() && r.empty())
				l.push_back(a);
			else if (a > l.back())
				l.push_back(a);
			else {
				if (r.empty())
					r.push_back(a);
				else if (a > r.back())
					r.push_back(a);
				else {
					cout << "NO" << endl;
					l.clear();
					r.clear();
					flag = 1;
					break;
				}
			}
		}
		if (flag == 1)
			k++;
		else {
			cout << "YES" << endl;
			l.clear();
			r.clear();
			k++;
		}
	}
}
int main() {
	int n;
	cin>>n;
	solve(n);
	return 0;
}