#include <iostream>

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

	for (i=0; i<num; i++) {
		std::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;

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

	return 0;
}