#include<iostream>

using namespace std;

int main(){

	int n;
	cin >> n;
	bool test = false;
	
	while( n-- ) {
		
		int A[10] = {0};
		int B[10] = {0};
	
		int j = 0, k = 0;
		int a;
		
		for(int i=0;i<10;i++) {
			
			cin >> a;
			
			if( a > A[j] ) {
				
				A[j+1] = a;
				j++;
				
			}
			else {
				if( a > B[k]) {
					
					B[k+1] = a;
					k++;
					
				}
			}
		}
		if ( j + k == 10)
			cout << "YES\n";
		else
			cout << "NO\n"; 
		
	}
	
    return 0;
}
