#include <iostream>
using namespace std;
double x1,y1,x2,y2;
double a,b,c,d;

double chaji(){
	double dx=x2-x1,dy=y2-y1;
	double aa=c-a,bb=d-b;
	return (dx*bb-dy*aa);
}
int main(){
	int N;cin>>N;
	while(N--){
		cin>>a>>b>>c>>d;
		cin>>x1>>y1>>x2>>y2;
		double ans1=chaji();
		x1=(x1+x2)/2;
		y1=(y1+y2)/2;
		x2=(a+c)/2;
		y2=(b+d)/2;
		double ans2=chaji();
		if(ans1==0&&ans2!=0)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}