#include <iostream>

using namespace std;

int main()
{
        int n;
        int b[6], c[6];

        b[5] = c[5] = 0;

        cin >> n;
        for (int i = 0; i < n; i++) {
                int ib = 0, ic = 0;

                for (int j = 0; j < 10; j++) {
                        if (j % 2) {
                                cin >> c[ic++];
                        }
                        else {
                                cin >> b[ib++];
                        }
                }
                int cnt = 0;
                while (b[cnt] < b[cnt + 1] && c[cnt] < c[cnt + 1]) {
                        cnt++;
                }

                cnt == 4 ? cout << "YES" : cout << "NO";
                cout << endl;
        }

        return 0;
}