# include<iostream>
using namespace std;

int main(){
	int N;
	bool N_Flag;
	int first, second, current;
	cin>>N;
	for(int i=0;i<N;i++){
		N_Flag = false;
		first = -1;
		second = -1;
		for(int k=0;k<10;k++){
			cin>>current;
			if(current>first){
				first = current;
			}else{
				if(current>second){
					second = current;
				}else{
					N_Flag = true;
//					break;  去掉break的目的是完成循环，耗尽多余的数字，以便下一循环的数据正确 
				}
			}
		}
		if(N_Flag){
			cout<<"NO"<<endl;
		}else{
			cout<<"YES"<<endl;
		}
	}
}
