#include<iostream>
using namespace std;

int main(){
	bool ans;
	int n;
	int a,b,la,lb;
	cin>>n;
	for(int i=0;i<n;i++){
		ans=true;
		cin>>la>>lb;
		for(int j=0;j<4;j++){
			cin>>a>>b;
			if(la>a||lb>b)ans=false;
			la=a;lb=b;
		}
		if(ans==true)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

}