#include <iostream>

using namespace std;

bool judge(int num){
	int i, n, q[2]={0,0};

	for (i=0; i<num; i++) {
		cin >> n;
		if (q[0]<n)
			q[0] = n;
		else if (q[1]<n)
			q[1] = n;
		else
			break;
	}

	return ((i==num)? true: false);
}

int main(){
	int i, n;

	cin >> n;
	for (i=0; i<n; i++)
		cout << (judge(10)? "YES": "NO") << endl;

	return 0;
}