#include<iostream>
#include<fstream>
#include<algorithm>
using namespace std;
int main()
{
	//freopen("3.txt","r",stdin);
	int n;
	cin >> n;
	while(n--)
	{
		int a[11];
		int flag=1;
		int b=0,c=0;
		for(int i=0;i<10;i++)
			{
				cin >> a[i];
				if(a[i]>b)
				{
					b=a[i];
				}
				else if(a[i]>c)
				{
					c=a[i];
				}
				else
				{
					flag=0;
				}
			}
		if(flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
 }
}