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

stack<int> b,c;

int main()
{
    int ball,n,flag=0;
    scanf("%d", &n);
    for(int i=0;i<n;++i) {
        for(int j=0;j<10;++j) {
            scanf("%d", &ball);
            if (b.empty())           { b.push(ball); continue; }
            else if (b.top() < ball) { b.push(ball); continue; }
            else if (c.empty())      { c.push(ball); continue; }
            else if (c.top() < ball) { c.push(ball); continue; }
            else { ++flag; break; }
        }
        (flag) ? puts("NO") : puts("YES");
    }

    return 0;
}