#include<iostream>
using namespace std;
#define MAX_N 100
#define MIN_N -10000000
int N;
int A[MAX_N][10];
int B = MIN_N, C = MIN_N;
int count;
bool b;

void solve(int i){ 
    if(count >= 10){//结束条件 
        return;
	}
	if(B > A[i][count] && C > A[i][count]){//不满足条件 
		b = false;
		return;
	}
	if(B < A[i][count] && C > A[i][count]){//大于B小于C 
		B = A[i][count];
		count++;
		solve(i);
	}
	if(B > A[i][count] && C < A[i][count]){//大于C小于B 
		C = A[i][count];
		count++;
		solve(i);
	}
	if(B <= A[i][count] && C <= A[i][count]){//比B和C任意中数字还要大 ，放在数字大的那边 
		if(B >= C){
			B = A[i][count];
		}
		else{
			C = A[i][count];
		}
		count++;
		solve(i);
	}
}
int main(){
	while(cin>>N && N != 0){
		for(int i = 0;i < N;i++){
			for(int j = 0;j < 10;j++){
				cin>>A[i][j];
			}
		}
		for(int i = 0;i < N;i++){
			b = true;
			count = 0;
		    solve(i); 
		    if(b){
			    cout<<"YES"<<endl; 
		    }
	    	else{
			    cout<<"NO"<<endl;
		    }
    	}
	}
}
