#include<iostream>
int topA=-1, topB=-1,B;
int times;
int main(){
	std::cin >> times;
	for (int j = 0; j < times; j++){
		for (int i = 0; i < 10; i++){
			std::cin >> B;
			if (topA == -1 && topB == -1){
				topA = B;
			}
			else if (topA != -1 && topB == -1){
				topB = B;
			}
				else if (topA < B){
					topA = B;
				}
				else if (topB < B){
					topB = B;
				}
				else{
					std::cout << "NO\n";
					goto rip;
				}
			}
		std::cout << "YES\n";
	rip:;
		}

}