#include <iostream>

using namespace std;

int main()
{
    int m;
    cin>>m;
    for(int l = 1; l <= m; ++l)
    {
        int llast = 0;
        int rlast = 0;
        int tmp;
        bool flag = true;
        for(int i = 0; i < 10; ++i)
        {
            cin>>tmp;
            if(tmp > llast)
            {
                if(tmp > rlast)
                {
                    if(tmp - llast < tmp - rlast)
                        llast = tmp;
                    else
                        rlast = tmp;
                }
                else
                    llast = tmp;
            }
            else if(tmp > rlast)
                rlast = tmp;
            else
                flag = false;
        }
        if(flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}
