#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cstdio>

using namespace std;



int main(){
	int n;

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

	return 0;
}