#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream> 
#define  ll long long
using namespace  std;
const    ll   len=105;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		vector<int>v1;
		vector<int>v2;
		int j=0;
		int w=0,temp;
		for(int i=0;i<10;i++)
		{
			cin>>temp;
			if(i==0)
				v1.push_back(temp);
			else
			{
				if(v1[v1.size()-1]<temp)
					v1.push_back(temp);
				else
				{
					if(v2.size()==0)
						v2.push_back(temp);
					if(v2[v2.size()-1]>temp&&v2.size()!=0)
						w=1;
					else
					if(v2[v2.size()-1]<temp&&v2.size()!=0)
						v2.push_back(temp); 	
				}  
			}
		}
		if(w==1)printf("NO\n");
		else
		 printf("YES\n");
	}
	return 0;
}
