#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;

int main(){
	int i,j,N,ball;
    cin>>N;
    for(i=0;i<N;i++){
		int ri=0,le=0,flg=0;
		for(j=0;j<10;j++){
			cin>>ball;
			if(ri<ball){
				ri=ball;
			}else if(le<ball){
				le=ball;
			}else{
				flg=1;
			}
		}		
		if(flg==0){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
    }
    return 0;
}