#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int n,date;
  int sta[2];
  cin >> n;
  while(n--){
    bool f = true;
    sta[0] = 0;
    sta[1] = 0;
    for(int i = 0;i < 10 ; i++){
      cin >> date;
      if(date > sta[0])sta[0] = date;
      else if(date > sta[1])sta[1] = date;
      else f = false;
    }
    if(f)puts("YES");
    else puts("NO");
  }
  return 0;
}