#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n; cin>>n;
    rep(i,n){
        vi v(11,0); pii pr; bool check=true;
        rep(i,10)cin>>v[i];
        pr.first=v[0];
        pr.second=v[1];
        for(int j=2; j<10;j++){
            int left=(-pr.first+v[j]); int right=(-pr.second+v[j]);
            if(pr.first>v[j]&&pr.second>v[j])check=false;
            else if(right>left&&v[j]>pr.first)pr.first=v[j];
            else if(right<left&&v[j]>pr.second)pr.second=v[j];
            else if(left>0&&right<0)pr.first=v[j];
            else if(left<0&&right>0)pr.second=v[j];
            else check=false;
            
        }
        if(check)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}