#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 f = true;
		vector<int> b, c; 
		for(int i = 0; i < 10; i++){
			cin >> a;
			if(f || b[b.size()-1] < a){
				b.push_back(a);
				f = false;
			}else{
				c.push_back(a);
			}
		}
		bool check = true;
		for(int i = 1; i < b.size() && check; i++){
			if(b[i] < b[i-1]){
				check = false;
			}
		}
		for(int i = 1; i < c.size() && check; i++){
			if(c[i] < c[i-1]){
				check = false;
			}
		}
		
		if(check){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}

	return 0;
}