#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  int n,x;
  cin>>n;
  rep(i,n){
    bool ok=true;
    int right,left=-INF;
    cin>>right;
    REP(i,1,10){
      //cout<<right<<" "<<left<<endl;
      cin>>x;
      if(right>x){
	if(left<x){
	  left=x;
	}else{
	  //cout<<x<<endl;
	  ok=false;
	  break;
	}
      }else{
	right=x;
      }
      
    }
    if(ok)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}