#include <iostream>
using namespace std;
int main( void )
{
	int N; // f[^ZbgÌÂ
	cin >> N;

	for ( int lpc = 0; lpc < N; lpc++ )
	{
		int a = 0;
		int b = 0;
		int cnt = 0;
		for ( int i = 0; i < 10; i++ )
		{
			int c;
			cin >> c;

			bool ok = false;
			if ( a < c )
			{
				if ( b < c && b > a )
					b = c;
				else
					a = c;
				ok = true;
			}
			else if ( b < c )
			{
				if ( a < c && a > b )
					a = c;
				else
					b = c;
				ok = true;
			}

			if ( ok == false )
			{
				while ( i+1 < 10 )
				{
					cin >> c;
					i++;
				}
				break;
			}

			cnt++;

		}

		cout << cnt << endl;
		if ( cnt == 10 )
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

	}

	return 0;
}