#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int n;
int array[10];

void solve() {
    int B=0;
    int C=0;
    rep(i,10) cin>>array[i];
    B = array[0];
    C = array[1];

    rep(i,10) {
        if(i==0 || i==1) continue;
        int t1 = array[i] - B;
        int t2 = array[i] - C;
        // cout<<t1<<","<<t2<<endl;
        if(t1<=0 && t2<=0) {
            cout<<"NO"<<endl;
            return;
        }
        else if(t1 > t2) {
            C = array[i];
        }
        else {
            B = array[i];
        }
    }

    cout<<"YES"<<endl;

}

int main() {
    cin>>n;
    rep(i,n) solve();
    return 0;
}