#include<iostream>
#include<cstdio>
#define Max_N 10

using namespace std;

int decide(int *a){
    int i = 1;
    int flag;
    int b[10]= {0};
    int c[10]= {0};
    b[0] = a[0];
    int i_b =1;
    int i_c =1;
    while(i < 10){
        if(b[i_b-1] > a[i] && c[i_c-1] > a[i]){
            flag = 1;
            break;
        }

        else if(b[i_b-1] > a[i] && c[i_c-1] < a[i]){
            c[i_c] = a[i];
            i_c++;
            flag = 0;
        }

        else if(b[i_b-1] < a[i] && c[i_c-1] > a[i]){
            b[i_b] = a[i];
            i_b++;
            flag = 0;
        }

        else{
            int minus_b = a[i]-b[i_b-1];
            int minus_c = a[i]-c[i_c-1];
            if(minus_b > minus_c){
                c[i_c] = a[i];
                i_c++;
            }
            else{
                b[i_b] = a[i];
                i_b++;
            }
            flag = 0;
        }
        i++;
    }
    return flag;
}

int main(){
    //input
    int a[Max_N];
    int n,m,k;
    scanf("%d", &n);
    int ans[n];
    for(m =0 ; m < n;m++){
        scanf("%d %d %d %d %d %d %d %d %d %d\n", &a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]);
        ans[m] = decide(a);
    }
    for(m = 0; m < n; m++){
        if(ans[m] == 0){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}
