#include<iostream>
using namespace std;

int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		int ball[11];
		bool flag = true;
		for(int i = 1;i <= 10;i++)
		{
			cin>>ball[i];
		}
		int left = -1,right = -1;
		for(int i = 1;i <= 10;i++)
		{
			if(ball[i] > left)
		    {
		    	left = ball[i];
		    	continue;
			}
			if(ball[i] > right)
			{
				right = ball[i];
				continue;
			}
			flag = false;
			break;
		}
		if(flag == true)
		{
			cout<<"YES"<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
}
