#include<iostream>
using namespace std;

int main() {
	int n;
	int balls[10];
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 10; j++) { cin >> balls[j]; }
		int b = 0, c = 0; int drop_balls = 0;
		for (int j = 0; j < 10; j++) {
			if (b < balls[j]) { b = balls[j]; drop_balls = j;}
			else if (c < balls[j]) { c = balls[j]; drop_balls = j;}
			else {cout << "NO" << endl;break;}
		}
		if (drop_balls == 9)cout << "YES" << endl;	
	}
}