#include <cstdio>
using namespace std;

int main()
{
    int N,ball[10],index=0;
    scanf("%d",&N);
    for(int i=0;i<N;++N) {
        for(int i=0;i<10;++i) {
            scanf("%d",&ball[i]);
        }
        while(index+2 <= 9) {
            if(ball[index] < ball[index+1]) {
                ++index;
                continue;
            } else if (ball[index] < ball[index+2]) {
                ++index;
                continue;
            } else {
                puts("NO");
                return -1;
            }
        }
        puts("YES");
        return 0;
    }
}