#include <iostream>
using namespace std;

int main(){
    int n,tmp,a = 0,b = 0;
    bool judge;
    cin >> n;
    while(n--){
        judge = true;
        for(int i=0;i<10;i++){
            cin >> tmp;
            if(tmp > a) a = tmp;
            else if(tmp > b) b = tmp;
            else judge = false;
        }
        if(judge) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}