#include <iostream>

using namespace std;

int main()
{
    int n;
    int a1, a2, b1, b2;

    cin >> n;
    for (int i = 0; i < n; i++) {
        bool ck = true;

        cin >> a1 >> b1;
        for (int j = 0; j < 4; j++) {
            cin >> a2 >> b2;

            if (a2 < a1 || b2 < b1) {
                ck = false;
                break;
            }
            a1 = a2;
            b1 = b2;

        }

        if (ck == true) 
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

    return 0;
}