#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;



int main(){
	int n;
	int left[11],right[11];
	int l=1,r=1;
	int number;
	bool T = 1;

	memset(left,0,sizeof(left));
	memset(right,0,sizeof(right));

	cin >> n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin >> number;
			if(left[l-1] < number && (number < right[r-1] || (left[l-1] > right[r-1] && right[r-1] < number))){
				left[l] = number;
				l++;
			}else if(right[r-1] < number){
				right[r] = number;
				r++;
			}else if(left[l-1] == right[r-1]){
				left[l] = number;
				l++;
			}else {
				cout << "NO" << endl;
				T = 0;
				break;
			}
		}

		if(T){
			cout << "YES" << endl;
			T = 1;
		}
	}
}