#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	for (int i = 0; i < n; i++) {
		int a = 0, b = 0;

		int f = 0;
		for (int i = 0; i < 10; i++) {
			int x;
			cin >> x;

			if (!i) {
				a = x;
			}
			else {
				if (x > a) {
					a = x;
				}
				else {
					if (!b) {
						b = x;
					}
					else if (x>b) {
						b = x;
					}
					else {
						f = 1;
					}
				}
			}
		}

		if (f) {
			cout << "NO" << endl;
		}
		else {
			cout << "YES" << endl;
		}
	}
}
