#include<iostream>
#include<cstdio>
#include<fstream>
#include<queue>
#include<vector>
#include<cstring>
#define MAX 20
#define INF 10000000

using namespace std;



int main(){
	int A[MAX];
	int B = 0;
	int C = 0;
	int n;
	cin >> n;
	while(n--){
		int i;
		B = 0;
		C = 0;
		for(i=0; i<10; i++)
			cin >> A[i];
		for(i=0; i<10; i++){
			if(A[i] > B){
				B = A[i];
				continue;
			}
			if(A[i] > C){
				C = A[i];
				continue;
			}
			else{
				cout << "NO" << endl;
				break;
			}
		}
		if(i == 10)
			cout << "YES" << endl;
	}
	return 0;
} 
