#include <iostream>
#include <array>
#include <vector>

using namespace std;



int main()
{
        int num = 0, tmp_right, tmp_left, ispush = 0, i, j;
        std::array< int, 10 > ar;
        std::vector< int > right, left;
        cin >> num;

        for ( j = 0 ; j < num ; j = j + 1 )
        {
                for ( i = 0 ; i < 10 ; i = i + 1 )
                {
                        cin >> ar[i];
                        ispush = 0;
                        if ( right.size() == 0 )
                        {
                                ispush = 1;
                                right.push_back( ar[i] );
                        }
                        else if ( right.size() != 0 )
                        {
                                tmp_right = right.back();
                                if ( tmp_right < ar[i] )
                                {
                                        right.push_back( ar[i] );
                                        ispush = 1;
                                }
                        }

                        if ( ispush == 0 )
                        {
                                if ( left.size() == 0 )
                                {
                                        ispush = 1;
                                        left.push_back( ar[i] );
                                }
                                else if ( left.size() != 0 )
                                {
                                        tmp_left = left.back();
                                        if ( tmp_left < ar[i] )
                                        {
                                                ispush = 1;
                                                left.push_back( ar[i] );
                                        }
                                }
                        }

                        if ( ispush == 0 )
                        {
                                cout << "NO" << endl;
                                break;
                        }
                        else
                        {
                                ispush = 0;
                        }
//                      cout << i << endl;
                        if ( i == 9 )
                        {
                                cout << "YES" << endl;
                        }


                }
                right.clear();
                left.clear();

        }


        return 0;
}