#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

using namespace std;

int main(){
	int n;

	cin >> n;

	while(n--){
		int tmp = 0;
		vector<int> b, c;
		bool limitB = false, limitC = false;

		for(int i = 0; i < 10; i++){
			limitB = false;
			limitC = false;
			cin >> tmp;

			if(b.size() == 0){
				b.push_back(tmp);
				continue;
			}
			else if(b.size() != 0 && c.size() == 0){
				if(b[b.size() - 1] < tmp){
					b.push_back(tmp);
					continue;
				}
				else{
					limitB = true;
				}
			}
			
			if(c.size() == 0){
				c.push_back(tmp);
				continue;
			}
			
			if(b[b.size() - 1] < tmp){
				b.push_back(tmp);
				continue;
			}
			else{
				limitB = true;
			}
		
			if(c[c.size() - 1] < tmp){
				c.push_back(tmp);
				continue;
			}
			else{
				limitC = true;
			}

			if(limitB && limitC){
				cout << "NO" << endl;
				break;
			}

		}
		if(!limitB || !limitC){
			cout << "YES" << endl;
		}
	}
	return 0;
}