#include<iostream>

int main()
{
	int n;
	std::cin >> n;
	
	while( n-- ){
		int a, b = 0, c = 0;
		bool f = true;
		
		for( int i = 0; i < 10; i++ ){
			std::cin >> a;
			
			if( b < a ){
				b = a;
			}
			else if( c < a ){
			 	c = a;
			}
			else{
			 	f = false;
			}
		}
		
		std::cout << ( f ? "YES" : "NO" ) << std::endl;
	}

 	return 0;
}