#include <iostream>
#include <array>

using namespace std;

int main()
{
        int set_number, L, R, flag = 0;
        cin >> set_number;
        array< int, 10 > ar;

        for ( int i = 0 ; i < set_number ; i++ )
        {
                for ( int j = 0 ; j < 10 ; j++ )
                {
                        cin >> ar[j];
                }

                L = ar[0];
                R = 0;
                for ( int j = 1 ; j < 10 ; j++ )
                {
                        if ( L < ar[j] )
                        {
                                L = ar[j];
                        }
                        else
                        {
                                if ( R < ar[j] )
                                {
                                        R = ar[j];
                                }
                                else
                                {
                                        cout << "NO" << endl;
                                        flag = 1;
                                        break;
                                }
                        }
                }

                if ( flag == 0 )
                {
                        cout << "YES" << endl;
                }
                flag = 0;
        }

        return 0;
}