#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;

int n, k;// , a = 0, b = 0;
bool f = 1;
stack<int> s1, s2;

int main(){
	cin >> n;
	REP(i, n){
		REP(j, 10){
			cin >> k;
			if (j == 0){
				s1.push(k);
				//a = s1.top();
			}
			else if (j == 1){
				s2.push(k);
				//b = s2.top();
			}
			else{
				if (s1.top() < k || s2.top() < k){
					if (k - s1.top() > k - s2.top()){
						s2.push(k);
					}
					else{
						s1.push(k);
					}
					//a = s1.top();
					//b = s2.top();
				}
				else{
					f = 0;
				}
			}
			//cout << a << b << "\n";
		}
		if (f){
			cout << "YES\n";
		}
		else{
			cout << "NO\n";
		}
	}
}