#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[11];
bool dfs(int i,int l,int r){
	if(i==10)return true;
	if(dfs(i+1,a[i],r)&&a[i]>l)return true;
	if(dfs(i+1,l,a[i])&&a[i]>r)return true;
	return false;
}
int main(){
	int T;
	cin>>T;
	while(T--){
	for(int i=0;i<10;i++)
		cin>>a[i];
	if(dfs(0,0,0))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}
	return 0;
}
