#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
  int n,a,b,c;
	cin>>n;
	for(;n>0;n--){
		int i;
		a = b = 0;
		for(i=0;i<10;i++){
			cin>>c;
			if(min(a,b) > c)break;
			else (a >= b && c > a) ? a = c : b = c;
		}
		if(i==10)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
  return 0;
}