#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
using namespace std;
int b = INT_MIN, c = INT_MIN;
bool push(int ball) {
    if(ball > b) b = ball;
    else if (ball > c) c = ball;
    else return(false);
    return(true);
}

int main(void) {
    int num, ans = 0; cin >> num;
    for(int r = 0; r < num; r++) {
        for(int c = 0; c < 10; c++) {
            int input; cin >> input;
            bool result = push(input);
            if(!result) ans -= 100;
        }
        if(ans == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return(0);
}