#include <iostream>
using namespace std;

bool checkStorable(const int (&nums)[10]);

int main()
{
    int n;
    int nums[10];
    
    cin >> n;
    for(int i=0; i<n; i++)
    {
       for(int j=0; j<10; j++)
        {
            cin >> nums[j];
        }
        if(checkStorable(nums))
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}

bool checkStorable(const int (&nums)[10])
{
    int prev_value_left = 0;
    int prev_value_right = 0;
    bool is_storable = true;
    
    for(int i=0; i<10; i++)
    {
        if(nums[i] > prev_value_left)
        {
            prev_value_left = nums[i];
        }
        else
        {
            if(nums[i] > prev_value_right)
            {
                prev_value_right = nums[i];
            }
            else
            {
                is_storable = false;
                break;
            }
        }
    }
    return is_storable;
}
