#include<iostream>
#include<cstdio>
int a[20];
using namespace std;
int main(){
	int m,n,p,q;
	scanf("%d",&n);
	while(n--){
		for(int i=0;i<10;i++){
			scanf("%d",&a[i]);
		}
		p = 0;q = -1;m = 1;
		for(int i=1;i<10;i++){
			if(q<0){
				if(a[i]>a[p]){
					p = i;m++;continue;
				}
				else{
					q = i;m++;continue;
				} 
			}
			else{
				if(a[p]>a[i]&&a[q]>a[i]) break;
				if(a[p]>a[i]&&a[q]<a[i]){
					q = i;m++;continue;
				} 
				if(a[p]<a[i]&&a[q]>a[i]){
					p = i;m++;continue;
				}
				if(a[p]<a[i]&&a[q]<a[i]){
					if(a[i]-a[p]>a[i]-a[q]){
						q = i;m++;continue;
					}
					else{
						p = i;m++;continue;
					}
				}
			}
		}
		if(m!=10) printf("NO\n");
		else printf("YES\n");
	} 
} 
