// AOJ 0033
#include<cstdio>
#define rep( i, a ) for( int i = 0; i != (a); ++i )

int main()
{
	int N;
	scanf( "%d", &N );

	rep( i, N )
	{
		int l = 0, r = 0;
		bool fl = true;

		rep( j, 10 )
		{
			int a;
			scanf( "%d", &a );

			if( a > l && a > r )
			{
				if( l > r )
					l = a;
				else
					r = a;
			}
			else if( a > l )
				l = a;
			else if( a > r )
				r = a;
			else
				fl = false;
		}

		puts( fl ? "YES" : "NO" );
	}

	return 0;
}