#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int ball[11];
    int n;
    int left = 0, right = 0;
    cin >> n;
    while(n--){
        for(int i = 0; i < 10; ++i) cin >> ball[i];
        bool flag = true;
        for(int i = 0; i < 10; ++i){
            int dl = ball[i] - left, dr = ball[i] - right;
            if(((dl >> 31) & 1) && ((dr >> 31) & 1)){
                flag = false;
                break;
            }
            else if(((dl >> 31) & 1) || ((dr >> 31) & 1)){
                if((dl >> 31) & 1) right = ball[i];
                else left = ball[i];
            }
            else{
                if(dl > dr) right = ball[i];
                else left = ball[i];
            }
        }
        cout << (flag ? "YES" : "NO") << endl;
    }
    return 0;
}