#include<stdio.h>
int main(void){
	int n,i,memo,flag,box1,box2,ball[11];
	scanf("%d",&n);
	while(n--){
		for(i=1;i<=10;i++){scanf("%d",&ball[i]);}
		flag=0;box1=0;box2=0;
		for(i=1;i<10;i++){
			if(ball[i]>box1){box1=ball[i];}
			else if(ball[i]>box2){box2=ball[i];}
			else {flag++;break;}
		}
		if(flag)printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}