#include <iostream>
using namespace std;

int main(){
  int n;
  int a[10];
  cin>>n;
  while(n--){
    for(int i=0;i<10;i++) cin>>a[i];
    for(int i=0;i<8;i++){
      if(a[i]>a[i+1]&&a[i]>a[i+2]&&a[i+1]>a[i+2]){
	cout<<"NO"<<endl;
	break;
      }
      if(i==7) cout<<"YES"<<endl;
    }
  }
  return 0;
}