#include <bits/stdc++.h>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
typedef long long ll;

int n;
int a[10];
int b=-1, c=-1;
string solve(){
	REP(i, 10)
	{
		cin >> a[i];
	}
	REP(i,8)
	{
		if (a[i]>a[i+1]&&a[i]>a[i+2]&&a[i+1]>a[i+2])
		{
			return "NO";
		}
	}
	return "YES";
}

int main()
{
	cin >> n;
	REP(i, n){
		cout << solve() << endl;
		
	}
	

	return 0;
}