#include <iostream>

using namespace std;

int main(){
  int n, num, count, before;

  cin >> n;

  for(int i = 0; i < n; i++){
    count = 0;
    before = 0;
    for(int j = 0; j < 10; j++){
      cin >> num;
      if(num < before){
        count++;
        if(count >= 2){
          cout << "NO" << endl;
          break;
        }
      }else{
        count = 0;
      }
      before = num;
    }
    if(count < 2) cout << "YES" << endl;
  }

  return 0;
}