// 
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int a[10], n;
bool bit(int n,vector<int>left,vector<int>right) {
	if (n == 10) {
		bool left_f = true;
		bool left_r = true;
		roop(i, left.size() - 1) { if (left[i + 1] <= left[i]) { return false; } }
		roop(i, right.size() - 1) { if (right[i + 1] <= right[i]) { return false; } }
		return true;
	}
	if (left[left.size() - 1] > a[n] && right[right.size() - 1] > a[n]) { return false; }
	vector<int>new_l = left;
	vector<int>new_r = right;
	
	new_l.push_back(a[n]);
	new_r.push_back(a[n]);
	return (bit(n + 1, new_l, right) || bit(n + 1, left, new_r));
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	vector<int>emptynow;
	roop(i, n) {
		roop(j, 10) {
			cin >> a[j];
		}
		if (bit(0, emptynow, emptynow)) { cout << "YES" << endl;}
		else { cout << "NO" << endl; }
	}
	return 0;
}
