#include <iostream>
#include <stack>

using namespace std;

int main()
{
    int n;
    cin >> n;

    for( int iii=0; iii<n; ++iii ) {
        stack<int> p[2];
        bool succ = true;

        for( int i=0; i<10; ++i ) {
            int ball;
            cin >> ball;

            if ( p[0].empty() ) {
                p[0].push( ball );

            } else {
                int diff = 999, t;
                for( int j=0; j<2; ++j ) {
                    int r = 0;
                    if ( !p[j].empty() )
                        r = ball - p[j].top();
                    if ( r < 0 )
                        continue;

                    if ( r < diff ) {
                        diff = r;
                        t = j;
                    }
                }

                if ( diff == 999 ) {
                    succ = false;
                } else {
                    p[t].push( ball );
                }
            }
        }

        cout << ( succ ? "YES" : "NO" ) << endl;
    }
}