#include <cstdio>
#include <queue>
using namespace std;

int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        queue < int > b, c;
        bool flag = true;
        
        b.push(0);
        c.push(0);
        
        int tmp;
        for (int i = 0; i < 10; i++){
            scanf("%d", &tmp);
            if (b.back() < tmp){
                b.push(tmp);
                if (i == 9) printf("YES\n");
            }
            else if (c.back() < tmp){
                c.push(tmp);
                if (i == 9) printf("YES\n");
            }
            else flag = false;
        }
        if (!flag) printf("NO\n");
    }
    
    return (0);
}