

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

/////////////////////////////////




int main(){
    int n;cin>>n;
    while(n--){
        int a[10];for(int i=0;i<=9;i++)cin>>a[i];
        int b=0,c=a[0];int i=1;
        while(i<=9){
            if(c<a[i])c=a[i];
            else if(b<a[i])b=a[i];
            else break;
            i++;
        }
        i==10?cout<<"YES"<<endl:cout<<"NO"<<endl;
    }
    return 0;
}

