#include <iostream>
using namespace std;

int main(){
  int n;
  int tmp[10];

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    int cnt;
    for(int j = 0 ; j < 10 ; j++){
      cin >> tmp[j];
    }
    
    cnt = 0;

    for(int j = 0 ; j < 10 ; j++){
      if(!(tmp[j] < tmp[j+1])) cnt++;
    }
    
    //cout << cnt << endl;

    if(cnt <= 3) cout << "YES"<< endl;
    else cout <<"NO"<<endl;
  }
  return 0;
}