//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
int in[10];
bool dfs(int n,vector<int> l,vector<int> r){
  if(n==10)return true;
  if(l.size()==0 or in[n]>l[l.size()-1]) 
  {
    l.push_back(in[n]);
    return dfs(n+1,l,r);
  }
  if(r.size()==0 or in[n]>r[r.size()-1] ){
    r.push_back(in[n]);
    return dfs(n+1,l,r);
  }
  return false;
  }
int main(){
  int d;
  cin>>d;
  for(int dd=0;dd<d;dd++){
    for(int i=0;i<10;i++){
      cin>>in[i];
    }
    vector<int> l,r;
    if(dfs(0,l,r )) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
  
  }
  return 0;
}
