#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
const int N =10;
int main()
{
	int n;
	scanf("%d",&n);
	while(n--){
		bool ans=true;
		int a,b=-1,c=-1;
		for(int i=0;i<N;i++)
		{
			scanf("%d",&a);
			if(ans){
				if(a>b)	b=a;
				else if(a>c)	c=a;
				else	ans=false;
			}
		}
		cout<<(ans ? "YES":"NO")<<endl;
	}




	
	return 0;
}