#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int loop,ball,hidari,migi;
int main(){
  cin>>loop;
  for(int i=0;i<loop;i++){
    hidari=migi=0;
    for(int j=0;j<10;j++){
      cin>>ball;
      if(ball<=migi&&ball<=hidari){cout<<"NO"<<endl;j=10;}
      if(hidari>migi){
	if(ball>hidari)hidari=ball;
	else migi=ball;
      }
      else{
	if(ball>migi)migi=ball;
	else hidari=ball;
	}
      if(j==9){
	cout<<"YES"<<endl;
      }
    }
  }
}