#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define OO 0x3d3d3d3d
#define sz(a) ((int)(a).size())
#define all(n) (n).begin(),(n).end()

using namespace std;
double const PI = acos(-1);
typedef complex<long double> point;
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a,b) ((b)-(a))
#define polar(r,t) ((r)*exp(point(0,(t))))
#define angle(v) (atan2((v).Y,(v).X))
#define length(v) ((long double)hypot((v).Y,(v).X))
#define lengthSqr(v) (dot(v,v))
#define dot(a,b) ((conj(a)*(b)).real())
#define cross(a,b) ((conj(a)*(b)).imag())
#define rotate(v,t) (polar(v,t))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define reflect(p,m) ((conj((p)/(m)))*(m))
#define normalize(p) ((p)/length(p))
#define same(a,b) (lengthSqr(vec(a,b))<EPS)
#define mid(a,b) (((a)+(b))/point(2,0))
#define perp(a) (point(-(a).Y,(a).X))
#define colliner pointOnLine
double to_degree(double radians){
    return radians * 180 / PI;
}
long double angle2(point v, point w){
    return acos(dot(v,w)/(lengthSqr(v)*lengthSqr(w)));
}
bool point_on_line(point a, point b, point p){
    return fabs(cross(vec(a, b), vec(a, p))) < EPS;
}
bool point_on_ray(point a, point b, point p){
    return point_on_line(a, b, p) && dot(vec(a, b), vec(a, p)) > -EPS;
}
bool point_on_segment(point a, point b, point p){
    return point_on_line(a, b, p) &&  dot(vec(a, b), vec(a, p)) > -EPS
                                      && dot(vec(b, a), vec(b, p)) > -EPS; ;
}
double triangle_area(double a, double b, double c){
    double s = (a+b+c)/2;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}
double triangle_area(point a, point b, point c){
    return triangle_area(length(vec(b, c)), length(vec(a, b)), length(vec(a, c)));
}
double SSS(double a, double b, double c){
    return acos( (b*b + c*c - a*a)/(2*b*c) );
}
double SSS(point a, point b, point c){
    /// return angle <bac
    return SSS(length(vec(b, c)), length(vec(a, b)), length(vec(a, c)));
}
#define NO { cout<<"NO"<<'\n'; continue;}
int main(){
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false), cin.tie(0);
#endif
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
//    point a(4,0), b(4,4), c(5,2);
//    cout<<point_on_line(a, b, c)<<endl;
//    cout<<point_on_segment(a, b, c)<<endl;
    int t;
    cin>>t;
    while (t--){
        map< pair<int,int> , vector<int> > mp;
        pair<point, point> a[3];
        point root;
        for(int i=0;i<3;i++){
            int x, y;
            cin>>x>>y;
            a[i].first = point(x, y);
            mp[{x,y}].push_back(i);
            cin>>x>>y;
            a[i].second = point(x, y);
            mp[{x,y}].push_back(i);
        }
        if(mp.size() != 5) NO
        int line1=0, line2=0, base;
        set<int> s = {0, 1, 2};
        for(auto ele : mp){
            if(ele.second.size() == 2){
                line1 = ele.second[0];
                line2 = ele.second[1];
                root = point(ele.first.first, ele.first.second);
                s.erase(line1), s.erase(line2);
            }
        }
        base = *s.begin();

        if( (point_on_segment(a[line1].first, a[line1].second, a[base].first)^point_on_segment(a[line2].first, a[line2].second, a[base].first))
            && (point_on_segment(a[line1].first, a[line1].second, a[base].second)^point_on_segment(a[line2].first, a[line2].second, a[base].second))){
            if(point_on_segment(a[line1].first, a[line1].second, a[base].second)) {
                swap(a[base].first, a[base].second);
            }
            if(a[line1].first != root) swap(a[line1].first, a[line1].second);
            if(a[line2].first != root) swap(a[line2].first, a[line2].second);

            double angle = SSS(root, a[base].first, a[base].second);
            if(angle < EPS || angle > PI/2 ) NO

            double sh, lg;
            sh = length(vec(root, a[base].first));
            lg = length(vec(a[base].first, a[line1].second));
            if(lg < sh) swap(lg, sh);
            if( sh/lg < 0.25 ) NO
            sh = length(vec(root, a[base].second));
            lg = length(vec(a[base].second, a[line2].second));
            if(lg < sh) swap(lg, sh);
            if( sh/lg < 0.25 ) NO
            cout<<"YES"<<endl;

        }
        else NO

    }

}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;

int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0,x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}
		cout<<line1<<" "<<line2<<" "<<line3<<endl;
		int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=a[line1].x1-a[line1].x2;
		Y1=a[line1].y1-a[line1].y2;
		X2=a[line2].x1-a[line2].x2;
		Y2=a[line2].y1-a[line2].y2;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}
		else {
		printf("NO\n");
		continue;}

		long long int angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(moline1*moline1+moline2*moline2-moline3*moline3)/(2*moline1*moline2);
		cout<<double(angle)<<endl;
		if(angle>int(angle)&&angle>=0&&angle-1<0) {
			flag=1;

		}
		else{
			printf("NO\n");
			continue;
		}
		if((moline3/bottom>=0.25)&&(moline3/bottom<=0.75)){
			printf("YES\n");

		}else {
			printf("NO\n");

		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if((X3==0&&Y3==0&&X4==0&&Y4==0)||((X1==X3)&&(Y1==Y3)&&(X2==X4)&&(Y2==Y4))||((X1==X4)&&(Y1==Y4)&&(X2==X3)&&(Y2==Y3))){
			printf("NO\n");
			continue;
		}
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1)||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	int x1;
	int y1;
	int x2;
	int y2;
} a[10001];
int n;

int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0,x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=a[line1].x1-a[line1].x2;
		Y1=a[line1].y1-a[line1].y2;
		X2=a[line2].x1-a[line2].x2;
		Y2=a[line2].y1-a[line2].y2;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}
		else {
		printf("NO\n");
		continue;}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle>0&&angle<1) {
			flag=1;

		}
		else{
			printf("NO\n");
			continue;
		}
		if((moline3/bottom>=0.25)&&(moline3/bottom<=0.75)){
			printf("YES\n");
			continue;
		}else {
			printf("NO\n");
			continue;
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(X3==0&&Y3==0&&X4==0&&Y4==0){
			printf("NO\n");
			continue;
		}
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1)||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;

int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=a[line1].x1-a[line1].x2;
		Y1=a[line1].y1-a[line1].y2;
		X2=a[line2].x1-a[line2].x2;
		Y2=a[line2].y1-a[line2].y2;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}
		else {
		printf("NO\n");
		continue;}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}

		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			printf("YES\n");

			continue;
		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			printf("YES\n");

			continue;
		}
		printf("NO\n");

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if((X3==0&&Y3==0&&X4==0&&Y4==0)||((X1==X3)&&(Y1==Y3)&&(X2==X4)&&(Y2==Y4))||((X1==X4)&&(Y1==Y4)&&(X2==X3)&&(Y2==Y3))){
			printf("NO\n");
			continue;
		}

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1&&abs(X1)>abs(X3)&&abs(Y1)>abs(Y3)&&abs(X2)>abs(X4)&&abs(Y2)>abs(Y4))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1&&abs(X2)>abs(X3)&&abs(Y2)>abs(Y3)&&abs(X1)>abs(X4)&&abs(Y1)>abs(Y4)){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if((X3==0&&Y3==0&&X4==0&&Y4==0)||((X1==X3)&&(Y1==Y3)&&(X2==X4)&&(Y2==Y4))||((X1==X4)&&(Y1==Y4)&&(X2==X3)&&(Y2==Y3))){
			printf("NO\n");
			continue;
		}

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1&&abs(X1)>=abs(X3)&&abs(Y1)>=abs(Y3)&&abs(X2)>=abs(X4)&&abs(Y2)>=abs(Y4))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1&&abs(X2)>=abs(X3)&&abs(Y2)>=abs(Y3)&&abs(X1)>=abs(X4)&&abs(Y1)>=abs(Y4)){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if((X3==0&&Y3==0&&X4==0&&Y4==0)||((X1==X3)&&(Y1==Y3)&&(X2==X4)&&(Y2==Y4))||((X1==X4)&&(Y1==Y4)&&(X2==X3)&&(Y2==Y3))){
			printf("NO\n");
			continue;
		}
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1)||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1)||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)));
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<0){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if((a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2))||(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2))){
			printf("YES\n");
			continue;

		}

			printf("NO\n");

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if((X3==0&&Y3==0&&X4==0&&Y4==0)||((X1==X3)&&(Y1==Y3)&&(X2==X4)&&(Y2==Y4))||((X1==X4)&&(Y1==Y4)&&(X2==X3)&&(Y2==Y3))){
			printf("NO\n");
			continue;
		}

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1&&abs(X1)>=abs(X3)&&abs(Y1)>=abs(Y3)&&abs(X2)>=abs(X4)&&abs(Y2)>=abs(Y4))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1&&abs(X2)>=abs(X3)&&abs(Y2)>=abs(Y3)&&abs(X1)>=abs(X4)&&abs(Y1)>=abs(Y4)){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)));
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<0){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)));
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<0){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		long long int lfx1=(4*x+leftx);
		long long int lfy1=(4*y+lefty);
		long long int lfx2=(4*leftx+x);
		long long int lfy2=(4*lefty+y);
		long long int rfx1=(4*x+rightx);
		long long int rfy1=(4*y+righty);
		long long int rfx2=(4*rightx+x);
		long long int rfy2=(4*righty+y);
		if((5*a[line3].x1<=max(lfx1,lfx2)&&5*a[line3].x1>=min(lfx1,lfx2)&&5*a[line3].y1<=max(lfy1,lfy2)&&5*a[line3].y1>=min(lfy1,lfy2)&&5*a[line3].x2<=max(rfx1,rfx2)&&5*a[line3].x2>=min(rfx1,rfx2)&&5*a[line3].y2<=max(rfy1,rfy2)&&5*a[line3].y2>=min(rfy1,rfy2))||(5*a[line3].x2<=max(lfx1,lfx2)&&5*a[line3].x2>=min(lfx1,lfx2)&&5*a[line3].y2<=max(lfy1,lfy2)&&5*a[line3].y2>=min(lfy1,lfy2)&&5*a[line3].x1<=max(rfx1,rfx2)&&5*a[line3].x1>=min(rfx1,rfx2)&&5*a[line3].y1<=max(rfy1,rfy2)&&5*a[line3].y1>=min(rfy1,rfy2))){
			printf("YES\n");
			continue;

		}

			printf("NO\n");

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if((X3==0&&Y3==0&&X4==0&&Y4==0)||((X1==X3)&&(Y1==Y3)&&(X2==X4)&&(Y2==Y4))||((X1==X4)&&(Y1==Y4)&&(X2==X3)&&(Y2==Y3))){
			printf("NO\n");
			continue;
		}
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2)&&pd(X1,X3)==1&&pd(Y1,Y3)==1&&pd(X2,X4)==1&&pd(Y2,Y4)==1)||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))&&pd(X1,X4)==1&&pd(Y1,Y4)==1&&pd(X2,X3)==1&&pd(Y2,Y3)==1){
			flag=1;
		}else {
			printf("NO1\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;

int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=a[line1].x1-a[line1].x2;
		Y1=a[line1].y1-a[line1].y2;
		X2=a[line2].x1-a[line2].x2;
		Y2=a[line2].y1-a[line2].y2;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}
		else {
		printf("NO\n");
		continue;}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)));
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<0){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx);
		double lfy1=(4*y+lefty);
		double lfx2=(4*leftx+x);
		double lfy2=(4*lefty+y);
		double rfx1=(4*x+rightx);
		double rfy1=(4*y+righty);
		double rfx2=(4*rightx+x);
		double rfy2=(4*righty+y);
		if((5*a[line3].x1<=max(lfx1,lfx2)&&5*a[line3].x1>=min(lfx1,lfx2)&&5*a[line3].y1<=max(lfy1,lfy2)&&5*a[line3].y1>=min(lfy1,lfy2)&&5*a[line3].x2<=max(rfx1,rfx2)&&5*a[line3].x2>=min(rfx1,rfx2)&&5*a[line3].y2<=max(rfy1,rfy2)&&5*a[line3].y2>=min(rfy1,rfy2))||(5*a[line3].x2<=max(lfx1,lfx2)&&5*a[line3].x2>=min(lfx1,lfx2)&&5*a[line3].y2<=max(lfy1,lfy2)&&5*a[line3].y2>=min(lfy1,lfy2)&&5*a[line3].x1<=max(rfx1,rfx2)&&5*a[line3].x1>=min(rfx1,rfx2)&&5*a[line3].y1<=max(rfy1,rfy2)&&5*a[line3].y1>=min(rfy1,rfy2))){
			printf("YES\n");
			continue;

		}

			printf("NO\n");

	}

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <iostream>
#include <cmath>
using namespace std;
int fang(int a,int b,int c,int d,int e,int f)//判断是否在三点是否共线
{
    if((long long)(f-b)*(c-a)==(long long)(d-b)*(e-a))
        return 1;
    return 0;
}
int xie(int x,int y,int a,int b,int p,int q)//判断两线段的夹角是否在0~90之间
{
    if((long long)(a-x)*(p-x)+(long long)(b-y)*(q-y)<0)
        return 0;
    return 1;
}
int juli(int x,int y,int m,int n,int a,int b)//判断分割的线段是否长：短<0.25
{
    if(x!=a)
    {
        if(a>x)
        {
            if((a-x)*5<(m-x)) return 0;
            if((a-x)*5>(m-x)*4) return 0;
            return 1;
        }
        else
        {
            if((x-a)*5<(x-m)) return 0;
            if((x-a)*5>(x-m)*4) return 0;
            return 1;
        }
    }
    else
    {
        if(b>y)
        {
            if((b-y)*5<(n-y))return 0;
            if((b-y)*5>(n-y)*4)return 0;
            return 1;
        }
        else
        {
            if((y-b)*5<(y-n))return 0;
            if((y-b)*5>(y-n)*4)return 0;
            return 1;
        }
    }
}
struct note
{
    int x,y,z,zz;
} a[7];
int main()
{
    int t,x,y,m,n,p,q,x1,y1,x2,y2;
    int count1,count2;
    //int cnt=0;
    while(~scanf("%d",&t))
    {
        while(t--)
        {
            //cnt++;
            for(int i=0; i<3; i++)
                scanf("%d%d%d%d",&a[i].x,&a[i].y,&a[i].z,&a[i].zz);
                /*if(cnt==11)
                {
                    for(int i=0;i<3;i++)
                       printf("(%d %d %d %d)\n",a[i].x,a[i].y,a[i].z,a[i].zz);
                }*/
            for(int i=0; i<2; i++)
                for(int j=i+1; j<3; j++)
                {
                    if(a[i].x==a[j].x&&a[i].y==a[j].y)
                    {
                        x=a[i].x,y=a[i].y;
                        m=a[i].z,n=a[i].zz;
                        p=a[j].z,q=a[j].zz;
                        count1=i;
                        count2=j;
                    }
                    else if(a[i].x==a[j].z&&a[i].y==a[j].zz)
                    {
                        x=a[i].x,y=a[i].y;
                        m=a[i].z,n=a[i].zz;
                        p=a[j].x,q=a[j].y;
                        count1=i;
                        count2=j;
                    }
                    else if(a[i].z==a[j].z&&a[i].zz==a[j].zz)
                    {
                        x=a[i].z,y=a[i].zz;
                        m=a[i].x,n=a[i].y;
                        p=a[j].x,q=a[j].y;
                        count1=i;
                        count2=j;
                    }
                    else if(a[i].z==a[j].x&&a[i].zz==a[j].y)
                    {
                        x=a[i].z,y=a[i].zz;
                        m=a[i].x,n=a[i].y;
                        p=a[j].z,q=a[j].zz;
                        count1=i;
                        count2=j;
                    }
                }
            for(int i=0; i<3; i++)
                if(i!=count1&&i!=count2)
                {
                    x1=a[i].x,y1=a[i].y,x2=a[i].z,y2=a[i].zz;
                    break;
                }
            int flag=1;
            if(xie(x,y,m,n,p,q)==0)
                flag=0;
            if(flag)
            {
                if(fang(x,y,m,n,x1,y1)&&fang(x,y,p,q,x2,y2))
                {
                    if(juli(x,y,m,n,x1,y1)==0)
                        flag=0;
                    if(juli(x,y,p,q,x2,y2)==0)
                        flag=0;
                }
                else if(fang(x,y,p,q,x1,y1)&&fang(x,y,m,n,x2,y2))
                {
                    if(juli(x,y,m,n,x2,y2)==0)
                        flag=0;
                    if(juli(x,y,p,q,x1,y1)==0)
                        flag=0;
                }
                else
                    flag=0;
            }
            if(flag==1)
                printf("YES\n");
            else
                printf("NO\n");
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)));
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<0){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)));
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<0){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=double(4*x+leftx)/5;
		double lfy1=double(4*y+lefty)/5;
		double lfx2=double(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)||a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			printf("YES\n");
			continue;

		}
		else {
			printf("NO\n");
			continue;
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;

int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0,x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=a[line1].x1-a[line1].x2;
		Y1=a[line1].y1-a[line1].y2;
		X2=a[line2].x1-a[line2].x2;
		Y2=a[line2].y1-a[line2].y2;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}
		else {
		printf("NO\n");
		continue;}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle>0&&angle<1) {
			flag=1;

		}
		else{
			printf("NO\n");
			continue;
		}
		if((moline3/bottom>=0.25)&&(moline3/bottom<=0.75)){
			printf("YES\n");
			continue;
		}else {
			printf("NO\n");
			continue;
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;

int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=a[line1].x1-a[line1].x2;
		Y1=a[line1].y1-a[line1].y2;
		X2=a[line2].x1-a[line2].x2;
		Y2=a[line2].y1-a[line2].y2;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}
		else {
		printf("NO\n");
		continue;}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			flag1=1;

		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			flag1=1;
		}
		if(flag1==1){
			printf("YES\n");
		}else{

		printf("NO\n");}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;
int pd(long long int a,long long int b){
	if((a>=0&&b>=0)||(a<0&&b<0)){
		return 1;
	}
	else return 0;
}
int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x1;
					righty=a[l].y1;

					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;

					rightx=a[l].x2;
					righty=a[l].y2;

					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=x-leftx;
		Y1=y-lefty;
		X2=x-rightx;
		Y2=y-righty;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;

		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}else {
			printf("NO\n");
			continue;
		}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)));
		if(moline3==0||moline1==0||moline2==0){
			printf("NO\n");
			continue;
		}
		if(angle<0){
			printf("NO\n");
			continue;
		}
		int flag1=0;
		double lfx1=(4*x+leftx)/5;
		double lfy1=(4*y+lefty)/5;
		double lfx2=(4*leftx+x)/5;
		double lfy2=double(4*lefty+y)/5;
		double rfx1=double(4*x+rightx)/5;
		double rfy1=double(4*y+righty)/5;
		double rfx2=double(4*rightx+x)/5;
		double rfy2=double(4*righty+y)/5;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)||a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			printf("YES\n");
			continue;

		}
		else {
			printf("NO\n");
			continue;
		}

	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
struct A {
	long long int x1;
	long long int y1;
	long long int x2;
	long long int y2;
} a[10001];
int n;

int main() {

	cin>>n;
	int i,j;
	for(i=0; i<n; i++) {
		for(j=0; j<3; j++) {
			cin>>a[j].x1>>a[j].y1>>a[j].x2>>a[j].y2;
		}
		int k=0,flag=0,line1,line2,line3,l=0;
		long long int x,y,leftx,lefty,rightx,righty;
		for(k=0; k<2; k++) {
			for(l=1;l<3; l++) {
				if(l!=k){

				if((a[k].x1==a[l].x1&&a[k].y1==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;

				}
				if((a[k].x1==a[l].x2&&a[k].y1==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x1;
					y=a[k].y1;
					leftx=a[k].x2;
					lefty=a[k].y2;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x2&&a[k].y2==a[l].y2)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x1;
					righty=a[l].y1;
					break;
				}
				if((a[k].x2==a[l].x1&&a[k].y2==a[l].y1)) {
					flag=1;
					line1=k;
					line2=l;
					x=a[k].x2;
					y=a[k].y2;
					leftx=a[k].x1;
					lefty=a[k].y1;
					rightx=a[l].x2;
					righty=a[l].y2;
					break;
				}
			}
			}
		}

		if(flag==0) {
			printf("NO\n");
			continue;
		}
		for(k=0;k<3;k++){
					if(k!=line1&&k!=line2){
						line3=k;

		}
		}

		long long int X1,Y1,X2,Y2,X3,Y3,X4,Y4;
		X1=a[line1].x1-a[line1].x2;
		Y1=a[line1].y1-a[line1].y2;
		X2=a[line2].x1-a[line2].x2;
		Y2=a[line2].y1-a[line2].y2;
		X3=x-a[line3].x1;
		Y3=y-a[line3].y1;
		X4=x-a[line3].x2;
		Y4=y-a[line3].y2;
		if(((X3*Y1==Y3*X1)&&(X4*Y2==Y4*X2))||((X3*Y2==Y3*X2)&&(X4*Y1==Y4*X1))){
			flag=1;
		}
		else {
		printf("NO\n");
		continue;}

		double angle;
		double moline1=sqrt((a[line1].x2-a[line1].x1)*(a[line1].x2-a[line1].x1)+(a[line1].y2-a[line1].y1)*(a[line1].y2-a[line1].y1));
		double moline2=sqrt((a[line2].x2-a[line2].x1)*(a[line2].x2-a[line2].x1)+(a[line2].y2-a[line2].y1)*(a[line2].y2-a[line2].y1));
		double moline3=sqrt((a[line3].x2-a[line3].x1)*(a[line3].x2-a[line3].x1)+(a[line3].y2-a[line3].y1)*(a[line3].y2-a[line3].y1));
		double bottom=sqrt((leftx-rightx)*(leftx-rightx)+(lefty-righty)*(lefty-righty));
		angle=(double((leftx-x)*(rightx-x)+(lefty-y)*(righty-y)))/(moline1*moline2);

		if(angle<=0&&angle==1){
			printf("NO\n");
			continue;
		}

		double ltwox=(x+leftx)/2;
		double ltwoy=(y+lefty)/2;
		double rtwox=(x+rightx)/2;
		double rtwoy=(y+righty)/2;
		double lfx1=(x+ltwox)/2;
		double lfy1=(y+ltwoy)/2;
		double lfx2=(leftx+ltwox)/2;
		double lfy2=(lefty+ltwoy)/2;
		double rfx1=(x+rtwox)/2;
		double rfy1=(y+rtwoy)/2;
		double rfx2=(rightx+rtwox)/2;
		double rfy2=(righty+rtwoy)/2;
		if(a[line3].x1<=max(lfx1,lfx2)&&a[line3].x1>=min(lfx1,lfx2)&&a[line3].y1<=max(lfy1,lfy2)&&a[line3].y1>=min(lfy1,lfy2)&&a[line3].x2<=max(rfx1,rfx2)&&a[line3].x2>=min(rfx1,rfx2)&&a[line3].y2<=max(rfy1,rfy2)&&a[line3].y2>=min(rfy1,rfy2)){
			printf("YES\n");
			continue;
		}
		if(a[line3].x2<=max(lfx1,lfx2)&&a[line3].x2>=min(lfx1,lfx2)&&a[line3].y2<=max(lfy1,lfy2)&&a[line3].y2>=min(lfy1,lfy2)&&a[line3].x1<=max(rfx1,rfx2)&&a[line3].x1>=min(rfx1,rfx2)&&a[line3].y1<=max(rfy1,rfy2)&&a[line3].y1>=min(rfy1,rfy2)){
			printf("YES\n");
			continue;
		}
		printf("NO\n");

	}

	return 0;
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pushf push_front
#define popf pop_front
#define pushb push_back
#define popb pop_back
// caution: MLE → comment below and use explicit "ll"
#define int ll

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pii>;
using vll = vector<pll>;
template <typename T> using pqmax = priority_queue<T>;
template <typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;

template <typename T> T inf() {return numeric_limits<T>::max()/2;}
template <typename T> inline T sq(T x){return x*x;}
template<typename A, typename B>
ostream& operator <<(ostream& os, const pair<A, B>& x) {
	os << x.fst << ' ' << x.snd; return os;
}
template<typename A, typename B>
istream& operator >>(istream& is, pair<A, B>& x) {
	is >> x.fst >> x.snd; return is;
}
template<typename A, typename B>
pair<A, B> operator +(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst+b.fst, a.snd+b.snd);
}
template<typename A, typename B>
pair<A, B> operator -(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst-b.fst, a.snd-b.snd);
}
template <typename T> auto cinvec(int n, int base=0) {
	vector<T> v(n+base);
	for (int i = base; i < sz(v); ++i) cin >> v[i];
	return v;
}
template <typename T> void memset(T& x, int val) {
	memset(x, val, sizeof(x));
}
template <typename T> void sort(T& x, int base=0) {
	sort(x.begin()+base, x.end());
}
template <typename T> void reverse(T& x, int base=0) {
	reverse(x.begin()+base, x.end());
}
template <typename T> void uniq(T& x, int base=0) {
	x.erase(unique(x.begin()+base, x.end()), x.end());
}
template <typename T> int lbpos(T& x, int val, int base=0) {
	return lower_bound(x.begin()+base, x.end(), val) - x.begin();
}
template <typename T> ll getsum(vector<T>& x, int base=0) {
	ll ret = 0;
	for (int i = base; i < sz(x); ++i) ret += x[i];
	return ret;
}
template <typename T> T getmax(vector<T>& x, int base=0) {
	return *max_element(x.begin()+base, x.end());
}
template <typename T> T getmin(vector<T>& x, int base=0) {
	return *min_element(x.begin()+base, x.end());
}
ll rand(ll mn, ll mx=LLONG_MAX/2){
	static mt19937 rng(time(0)^ll(new int));
	return uniform_int_distribution<ll>(mn, mx-1)(rng);
}

/***********************************************************************************/
#define MULTITEST 1
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
const ll MOD = 998244353;
const ll MAX = 3002;

/***********************************************************************************/
const double PI = 2*acos(0.0);
template <typename T>
bool equal(T a, T b) {
	if constexpr(is_same_v<T, double>) {
		double diff = fabs(a-b);
		if (diff < 1e-10) return true;
		return diff < 1e-8 * max(fabs(a), fabs(b));
	}
	return a==b;
}

template <typename T>
struct VT {
	T x, y, id;
	VT(T _x=0, T _y=0) : x(_x),y(_y){}
	bool operator ==(const VT& rhs) const {
		return equal(x, rhs.x) && equal(y, rhs.y);
	}
	bool operator <(const VT& rhs) const {
		if (*this == rhs) return false;
		return !equal(x, rhs.x) ? x < rhs.x : y < rhs.y;
	}
	bool operator <=(const VT& rhs) const {
		return *this == rhs || *this < rhs;
	}
	VT operator +(const VT& rhs) const {
		return VT(x+rhs.x, y+rhs.y);
	}
	VT operator -(const VT& rhs) const {
		return VT(x-rhs.x, y-rhs.y);
	}
	VT operator -() const {
		return VT(-x, -y);
	}
	VT operator *(T rhs) const {
		return VT(x*rhs, y*rhs);
	}
	T norm() const { // 벡터의 크기 반환, 정수형의 경우 크기 제곱
		if constexpr(is_same_v<T, double>) return hypot(x, y);
		return sq(x)+sq(y);
	}
	VT normalize() const { // 현재 벡터의 방향을 갖는 단위벡터 반환
		if (equal(norm(), (T)0)) return *this;
		T div = 0;
		if constexpr(is_same_v<T, double>) div = norm();
		else div = gcd(x, y);
		return VT(x/div, y/div);
	}
	T dot(const VT& rhs) const { // 내적
		return x*rhs.x + y*rhs.y;
	}
	T cross(const VT& rhs) const { // 외적
		return x*rhs.y - y*rhs.x;
	}
	// 현재 벡터를 rhs에 사영한 벡터를 반환
	VT project(const VT& rhs) const {
		if constexpr(is_same_v<T, double>) {
			VT r = rhs.normalize();
			return r * r.dot(*this);
		}
		else {assert(0); return VT(0, 0);}
	}
};
template<typename T>
ostream& operator <<(ostream& os, const VT<T>& p) {
	os << p.x << ' ' << p.y; return os;
}
template<typename T>
istream& operator >>(istream& is, VT<T>& p) {
	is >> p.x >> p.y; return is;
}

template <typename T>
T ccw(VT<T> a, VT<T> b, VT<T> c) {
	return (b-a).cross(c-a);
}
// 점 p,a,b가 일직선상에 있을 때 p가 [a, b]에 있는지 본다
template <typename T>
bool inRange(VT<T> p, VT<T> a, VT<T> b) {
	if (b < a) swap(a, b);
	return a <= p && p <= b;
}

// ab를 포함하는 직선과 cd를 포함하는 직선의 교점을 구해 x에 저장
// 교점이 존재하면 참, 존재하지 않으면(평행/겹침) 거짓을 반환
template <typename T>
bool lineIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		double det = (b-a).cross(d-c);
		if (equal(det, (T)0)) return false;
		x = a + (b-a) * ((c-a).cross(d-c) / det);
		return true;
	}
	else {assert(0); return false;}
}

// ab선분과 cd선분이 겹치는지 여부를 반환 (오버플로우 주의)
template <typename T>
bool segIntersect(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	T tmp1 = ccw(a, b, c), tmp2 = ccw(a, b, d);
	T tmp3 = ccw(c, d, a), tmp4 = ccw(c, d, b);
	T ab = 0, cd = 0;
	if constexpr(is_same_v<T, double>) {
		ab = tmp1*tmp2; cd = tmp3*tmp4;
	}
	else {
		if (tmp1 != 0 && tmp2 != 0) {
			tmp1 /= abs(tmp1); tmp2 /= abs(tmp2);
			ab = tmp1*tmp2;
		}
		if (tmp3 != 0 && tmp4 != 0) {
			tmp3 /= abs(tmp3); tmp4 /= abs(tmp4);
			cd = tmp3*tmp4;
		}
	}
	// 두 선분이 한 직선 위에 있거나 끝 점이 겹치는 경우
	if (equal(ab, (T)0) && equal(cd, (T)0)) {
		if (b < a) swap(a, b);
		if (d < c) swap(c, d);
		return !(d < a || b < c);
	}
	// 선분에 다른 선분이 접촉한 경우도 고려
	return (equal(ab, (T)0) || ab < 0) &&
		(equal(cd, (T)0) || cd < 0);
}

// ab선분과 cd선분이 겹치는지 여부를 반환
// 겹치는 경우 교점(무한개면 임의의 교점)을 x에 저장
template <typename T>
bool segIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		if (lineIntersection(a, b, c, d, x))
			return inRange(x, a, b) && inRange(x, c, d);
		if (b < a) swap(a, b); if (d < c) swap(c, d);
		if (!equal(ccw(a, b, c), (T)0) || d < a || b < c) return false;
		if (a < c) x = c; else x = a;
		return true;
	}
	else {assert(0); return false;}
}

// 점 p에서 ab직선에 내린 수선의 발을 반환
template <typename T>
VT<T> foot(VT<T> p, VT<T> a, VT<T> b) {
	return a + (p-a).project(b-a);
}

// 점 p에서 ab직선까지의 최소 거리를 반환
template <typename T>
T pointToLine(VT<T> p, VT<T> a, VT<T> b) {
	return (p-foot(p, a, b)).norm();
}

// 점 p에서 ab선분까지의 최소 거리를 반환
template <typename T>
T pointToSeg(VT<T> p, VT<T> a, VT<T> b) {
	VT h = foot(p, a, b);
	if (inRange(h, a, b)) return (p-h).norm();
	return min((p-a).norm(), (p-b).norm());
}

// ab선분에서 cd선분까지의 최소 거리를 반환
template <typename T>
T segToSeg(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	if (segIntersect(a, b, c, d)) return (T)0;
	return min({pointToSeg(a, c, d), pointToSeg(b, c, d),
		pointToSeg(c, a, b), pointToSeg(d, a, b)});
}

// 다각형 p의 넓이를 반환, 정수형의 경우 2로 나누지 않음
template <typename T>
T area(const vector<VT<T>>& p) {
	T ret = 0;
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		ret += p[i].cross(p[j]);
	}
	if constexpr(is_same_v<T, double>) return fabs(ret)/2;
	else return abs(ret);
}

// 점 q가 다각형 p의 경계에 위치하는지 여부를 반환
template <typename T>
bool onBound(const vector<VT<T>>& p, VT<T> q) {
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		if (equal(ccw(q, p[i], p[j]), (T)0) &&
			inRange(q, p[i], p[j]))
			return true;
	}
	return false;
}

// 점 q가 다각형 p의 내부에 있는지 외부에 있는지를 판별
template <typename T>
bool inside(const vector<VT<T>>& p, VT<T> q) {
	if constexpr(is_same_v<T, double>) {
		if (onBound(p, q)) return false;
		int cross = 0, n = sz(p);
		for (int i = 0; i < n; ++i) {
			int j = (i+1)%n;
			if ((!equal(p[i].y, q.y) && p[i].y > q.y) !=
				(!equal(p[j].y, q.y) && p[j].y > q.y)) {
				double atX = (q.y - p[i].y) * (p[j].x - p[i].x) /
					(p[j].y - p[i].y) + p[i].x;
				if (q.x < atX) ++cross;
			}
		}
		return cross%2 > 0;
	}
	else {assert(0); return false;}
}

bool isA(VT<int> from, VT<int> to1, VT<int> to2, VT<int> a, VT<int> b) {
	// 1. from-to1, from-to2의 각도
	if ((to1-from).cross(to2-from) == 0) return false;
	if (to1-from.dot(to2-from) < 0) return false;

	// 2. from-to 와 a-b의 교차점
	for (auto to : {to1, to2}) {
		// 선분이 삐죽 튀어나와도 안되네 문제 설명 실환가
		if (ccw(from, to, a) && ccw(from, to, b)) return false;
		// 교차점이 정확히 from-to의 p:q 내분지점에 있는 경우
		bool bound = false;
		for (auto p : {1, 4}) {
			int q = 5-p;
			int crossX = p*to.x + q*from.x;
			int crossY = p*to.y + q*from.y;
			if (crossX%5 || crossY%5) continue;
			crossX /= 5; crossY /= 5;
			if (ccw(a, b, VT<int>(crossX, crossY)) == 0) {
				bound = true; break;
			}
		}
		if (bound) continue;

		VT<double> dfrom(from.x, from.y);
		VT<double> dto(to.x, to.y);
		VT<double> da(a.x, a.y), db(b.x, b.y);
		VT<double> cross;

		assert(segIntersection(dfrom, dto, da, db, cross));
		double dist1 = (dfrom-cross).norm();
		double dist2 = (dto-cross).norm();
		if (equal(dist1, 0.0) || equal(dist2, 0.0)) return false;
		if (dist1 > dist2) swap(dist1, dist2);
		double ratio = dist1/dist2;
		if (ratio < 0.25) return false;
	}
	return true;
}

void solve(int tc) {
	VT<int> p[3][2];
	for (int i = 0; i < 3; ++i) {
		cin >> p[i][0] >> p[i][1];
	}
	bool valid = false;
	for (int i = 0; i < 3; ++i)
		for (int j = i+1; j < 3; ++j) {
			int k = 3-i-j;
			for (int x = 0; x < 2; ++x)
				for (int y = 0; y < 2; ++y)
					if (p[i][x] == p[j][y]) {
						valid |= isA(p[i][x], p[i][1-x], p[j][1-y], p[k][0], p[k][1]);
					}
		}
	cout << (valid ? "YES" : "NO") << '\n';
}

/***********************************************************************************/
signed main(signed argc, char *argv[]) {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(11);
	bool mult = (MULTITEST && !(argc == 2 && (string)argv[1] == "test"));
	int T = 1; if (mult) cin >> T;
	for (int tc = 1; tc <= T; ++tc) solve(tc);
}


#include <bits/stdc++.h>
#define fst first
#define snd second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)x.size()
#define pushf push_front
#define popf pop_front
#define pushb push_back
#define popb pop_back
// caution: MLE → comment below and use explicit "ll"
#define int ll

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pii>;
using vll = vector<pll>;
template <typename T> using pqmax = priority_queue<T>;
template <typename T> using pqmin = priority_queue<T, vector<T>, greater<T>>;

template <typename T> T inf() {return numeric_limits<T>::max()/2;}
template <typename T> inline T sq(T x){return x*x;}
template<typename A, typename B>
ostream& operator <<(ostream& os, const pair<A, B>& x) {
	os << x.fst << ' ' << x.snd; return os;
}
template<typename A, typename B>
istream& operator >>(istream& is, pair<A, B>& x) {
	is >> x.fst >> x.snd; return is;
}
template<typename A, typename B>
pair<A, B> operator +(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst+b.fst, a.snd+b.snd);
}
template<typename A, typename B>
pair<A, B> operator -(const pair<A, B>& a, const pair<A, B>& b) {
	return pair<A, B>(a.fst-b.fst, a.snd-b.snd);
}
template <typename T> auto cinvec(int n, int base=0) {
	vector<T> v(n+base);
	for (int i = base; i < sz(v); ++i) cin >> v[i];
	return v;
}
template <typename T> void memset(T& x, int val) {
	memset(x, val, sizeof(x));
}
template <typename T> void sort(T& x, int base=0) {
	sort(x.begin()+base, x.end());
}
template <typename T> void reverse(T& x, int base=0) {
	reverse(x.begin()+base, x.end());
}
template <typename T> void uniq(T& x, int base=0) {
	x.erase(unique(x.begin()+base, x.end()), x.end());
}
template <typename T> int lbpos(T& x, int val, int base=0) {
	return lower_bound(x.begin()+base, x.end(), val) - x.begin();
}
template <typename T> ll getsum(vector<T>& x, int base=0) {
	ll ret = 0;
	for (int i = base; i < sz(x); ++i) ret += x[i];
	return ret;
}
template <typename T> T getmax(vector<T>& x, int base=0) {
	return *max_element(x.begin()+base, x.end());
}
template <typename T> T getmin(vector<T>& x, int base=0) {
	return *min_element(x.begin()+base, x.end());
}
ll rand(ll mn, ll mx=LLONG_MAX/2){
	static mt19937 rng(time(0)^ll(new int));
	return uniform_int_distribution<ll>(mn, mx-1)(rng);
}

/***********************************************************************************/
#define MULTITEST 1
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
const ll MOD = 998244353;
const ll MAX = 3002;

/***********************************************************************************/
const double PI = 2*acos(0.0);
template <typename T>
bool equal(T a, T b) {
	if constexpr(is_same_v<T, double>) {
		double diff = fabs(a-b);
		if (diff < 1e-10) return true;
		return diff < 1e-8 * max(fabs(a), fabs(b));
	}
	return a==b;
}

template <typename T>
struct VT {
	T x, y;
	VT(T _x=0, T _y=0) : x(_x),y(_y){}
	bool operator ==(const VT& rhs) const {
		return equal(x, rhs.x) && equal(y, rhs.y);
	}
	bool operator <(const VT& rhs) const {
		if (*this == rhs) return false;
		return !equal(x, rhs.x) ? x < rhs.x : y < rhs.y;
	}
	bool operator <=(const VT& rhs) const {
		return *this == rhs || *this < rhs;
	}
	VT operator +(const VT& rhs) const {
		return VT(x+rhs.x, y+rhs.y);
	}
	VT operator -(const VT& rhs) const {
		return VT(x-rhs.x, y-rhs.y);
	}
	VT operator -() const {
		return VT(-x, -y);
	}
	VT operator *(T rhs) const {
		return VT(x*rhs, y*rhs);
	}
	T norm() const { // 벡터의 크기 반환, 정수형의 경우 크기 제곱
		if constexpr(is_same_v<T, double>) return hypot(x, y);
		return sq(x)+sq(y);
	}
	VT normalize() const { // 현재 벡터의 방향을 갖는 단위벡터 반환
		if (equal(norm(), (T)0)) return *this;
		T div = 0;
		if constexpr(is_same_v<T, double>) div = norm();
		else div = gcd(x, y);
		return VT(x/div, y/div);
	}
	T dot(const VT& rhs) const { // 내적
		return x*rhs.x + y*rhs.y;
	}
	T cross(const VT& rhs) const { // 외적
		return x*rhs.y - y*rhs.x;
	}
	// 현재 벡터를 rhs에 사영한 벡터를 반환
	VT project(const VT& rhs) const {
		if constexpr(is_same_v<T, double>) {
			VT r = rhs.normalize();
			return r * r.dot(*this);
		}
		else {assert(0); return VT(0, 0);}
	}
};
template<typename T>
ostream& operator <<(ostream& os, const VT<T>& p) {
	os << p.x << ' ' << p.y; return os;
}
template<typename T>
istream& operator >>(istream& is, VT<T>& p) {
	is >> p.x >> p.y; return is;
}

template <typename T>
T ccw(VT<T> a, VT<T> b, VT<T> c) {
	return (b-a).cross(c-a);
}
// 점 p,a,b가 일직선상에 있을 때 p가 [a, b]에 있는지 본다
template <typename T>
bool inRange(VT<T> p, VT<T> a, VT<T> b) {
	if (b < a) swap(a, b);
	return a <= p && p <= b;
}

// ab를 포함하는 직선과 cd를 포함하는 직선의 교점을 구해 x에 저장
// 교점이 존재하면 참, 존재하지 않으면(평행/겹침) 거짓을 반환
template <typename T>
bool lineIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		double det = (b-a).cross(d-c);
		if (equal(det, (T)0)) return false;
		x = a + (b-a) * ((c-a).cross(d-c) / det);
		return true;
	}
	else {assert(0); return false;}
}

// ab선분과 cd선분이 겹치는지 여부를 반환
template <typename T>
bool segIntersect(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	T tmp1 = ccw(a, b, c), tmp2 = ccw(a, b, d);
	T tmp3 = ccw(c, d, a), tmp4 = ccw(c, d, b);
	T ab = 0, cd = 0;
	if constexpr(is_same_v<T, double>) {
		ab = tmp1*tmp2; cd = tmp3*tmp4;
	}
	else {
		if (tmp1 != 0 && tmp2 != 0) {
			tmp1 /= abs(tmp1); tmp2 /= abs(tmp2);
			ab = tmp1*tmp2;
		}
		if (tmp3 != 0 && tmp4 != 0) {
			tmp3 /= abs(tmp3); tmp4 /= abs(tmp4);
			cd = tmp3*tmp4;
		}
	}
	// 두 선분이 한 직선 위에 있거나 끝 점이 겹치는 경우
	if (equal(ab, (T)0) && equal(cd, (T)0)) {
		if (b < a) swap(a, b);
		if (d < c) swap(c, d);
		return !(d < a || b < c);
	}
	// 선분에 다른 선분이 접촉한 경우도 고려
	return (equal(ab, (T)0) || ab < 0) &&
		(equal(cd, (T)0) || cd < 0);
}

// ab선분과 cd선분이 겹치는지 여부를 반환
// 겹치는 경우 교점(무한개면 임의의 교점)을 x에 저장
template <typename T>
bool segIntersection(VT<T> a, VT<T> b, VT<T> c, VT<T> d, VT<T>& x) {
	if constexpr(is_same_v<T, double>) {
		if (lineIntersection(a, b, c, d, x))
			return inRange(x, a, b) && inRange(x, c, d);
		if (b < a) swap(a, b); if (d < c) swap(c, d);
		if (!equal(ccw(a, b, c), (T)0) || d < a || b < c) return false;
		if (a < c) x = c; else x = a;
		return true;
	}
	else {assert(0); return false;}
}

// 점 p에서 ab직선에 내린 수선의 발을 반환
template <typename T>
VT<T> foot(VT<T> p, VT<T> a, VT<T> b) {
	return a + (p-a).project(b-a);
}

// 점 p에서 ab직선까지의 최소 거리를 반환
template <typename T>
T pointToLine(VT<T> p, VT<T> a, VT<T> b) {
	return (p-foot(p, a, b)).norm();
}

// 점 p에서 ab선분까지의 최소 거리를 반환
template <typename T>
T pointToSeg(VT<T> p, VT<T> a, VT<T> b) {
	VT h = foot(p, a, b);
	if (inRange(h, a, b)) return (p-h).norm();
	return min((p-a).norm(), (p-b).norm());
}

// ab선분에서 cd선분까지의 최소 거리를 반환
template <typename T>
T segToSeg(VT<T> a, VT<T> b, VT<T> c, VT<T> d) {
	if (segIntersect(a, b, c, d)) return (T)0;
	return min({pointToSeg(a, c, d), pointToSeg(b, c, d),
		pointToSeg(c, a, b), pointToSeg(d, a, b)});
}

// 다각형 p의 넓이를 반환, 정수형의 경우 2로 나누지 않음
template <typename T>
T area(const vector<VT<T>>& p) {
	T ret = 0;
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		ret += p[i].cross(p[j]);
	}
	if constexpr(is_same_v<T, double>) return fabs(ret)/2;
	else return abs(ret);
}

// 점 q가 다각형 p의 경계에 위치하는지 여부를 반환
template <typename T>
bool onBound(const vector<VT<T>>& p, VT<T> q) {
	for (int i = 0; i < p.size(); ++i) {
		int j = (i+1)%p.size();
		if (equal(ccw(q, p[i], p[j]), (T)0) &&
			inRange(q, p[i], p[j]))
			return true;
	}
	return false;
}

// 점 q가 다각형 p의 내부에 있는지 외부에 있는지를 판별
template <typename T>
bool inside(const vector<VT<T>>& p, VT<T> q) {
	if constexpr(is_same_v<T, double>) {
		if (onBound(p, q)) return false;
		int cross = 0, n = sz(p);
		for (int i = 0; i < n; ++i) {
			int j = (i+1)%n;
			if ((!equal(p[i].y, q.y) && p[i].y > q.y) !=
				(!equal(p[j].y, q.y) && p[j].y > q.y)) {
				double atX = (q.y - p[i].y) * (p[j].x - p[i].x) /
					(p[j].y - p[i].y) + p[i].x;
				if (q.x < atX) ++cross;
			}
		}
		return cross%2 > 0;
	}
	else {assert(0); return false;}
}

bool isA(VT<int> from, VT<int> to1, VT<int> to2, VT<int> a, VT<int> b) {
	// 1. from-to1, from-to2의 각도
	if ((to1-from).cross(to2-from) == 0) return false;
	if ((to1-from).dot(to2-from) < 0) return false;

	// 2. ab선분은 from-to1, from-to2에 걸침
	int cval1 = ccw(from, to1, a), cval2 = ccw(from, to1, b);
	if (cval1 != 0 && cval2 != 0) return false;
	if (cval2 == 0) swap(a, b);

	if (!inRange(a, from, to1)) return false;
	if (!segIntersect(from, to1, a, b)) {
		cout << from << ' ' << to1 << ' ' << to2 << ' ' <<
			a << ' ' << b << endl;
	}
	int dist1 = (a-from).norm(), dist2 = (a-to1).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;

	if (!inRange(b, from, to2)) return false;
	if (!segIntersect(from, to2, a, b)) {
		cout << from << ' ' << to1 << ' ' << to2 << ' ' <<
			a << ' ' << b << endl;
	}
	dist1 = (b-from).norm(); dist2 = (b-to2).norm();
	if (dist1 > dist2) swap(dist1, dist2);
	if (16*dist1 < dist2) return false;
	return true;
}

void solve(int tc) {
	VT<int> p[3][2];
	for (int i = 0; i < 3; ++i) {
		cin >> p[i][0] >> p[i][1];
	}
	bool valid = false;
	for (int i = 0; i < 3; ++i)
		for (int j = i+1; j < 3; ++j) {
			int k = 3-i-j;
			for (int x = 0; x < 2; ++x)
				for (int y = 0; y < 2; ++y)
					if (p[i][x] == p[j][y]) {
						valid |= isA(p[i][x], p[i][1-x], p[j][1-y], p[k][0], p[k][1]);
					}
		}
	cout << (valid ? "YES" : "NO") << '\n';
}

/***********************************************************************************/
signed main(signed argc, char *argv[]) {
	ios::sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(11);
	bool mult = (MULTITEST && !(argc == 2 && (string)argv[1] == "test"));
	int T = 1; if (mult) cin >> T;
	for (int tc = 1; tc <= T; ++tc) solve(tc);
}