//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ll,ll> x[MX],y[MX];
//ld ep = 1e-9;

ll cross(pair <ll,ll> u,pair <ll,ll> v){
    return u.fs*v.sc - u.sc*v.fs;
}

void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

        ll flag = 0;
        for(ll i = 1 ; i<= 3; i++){
            for(ll j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(x[a1] == x[a2]){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(x[a1] == y[a2] ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(y[a1] == x[a2]){
                    cond = 3;
                }
                else if(y[a1] == y[a2]){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
                pair <ll,ll > u= {(x[a1].fs-y[a1].fs),(x[a1].sc-y[a1].sc)};
                pair <ll,ll > v= {(y[a2].fs-x[a2].fs),(y[a2].sc-x[a2].sc)};
                ll aux = cross(u,v);
              	//trace(aux);
                if(aux < 0) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ll e1,e2,e3;
                ll p1,p2,p3;
                e1 =  (y[a1].fs-x[a1].fs);
                e2 =  (x[a1].sc-y[a1].sc);
                e3 =  (y[a1].sc - x[a1].sc)*x[a1].fs - x[a1].sc*(y[a1].fs-x[a1].fs);
                p1 =  (y[a2].fs-x[a2].fs);
                p2 =  (x[a2].sc-y[a2].sc);
                p3 =  (y[a2].sc - x[a2].sc)*x[a2].fs - x[a2].sc*(y[a2].fs-x[a2].fs);
                //trace(e1,e2,e3);
                //trace(p1,p2,p3);
                ll rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ll rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ll rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ll rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	//trace(rep1,rep2,rep3,rep4);
                if((rep1 == 0 && rep4 == 0) || (rep2 ==0 && rep3 == 0 )){
                    if(rep1 == 0 && rep4 ==0){
                        ll k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                        ll k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                        ll j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                        ll j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                        if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                        else{
                            ini(cond,a1,a2,a3);
                            continue;
                        }
                        k1 = min(4*x[a1].fs+y[a1].fs,4*y[a1].fs+x[a1].fs);k2 = max(4*x[a1].fs+y[a1].fs,4*y[a1].fs+x[a1].fs);
                        k3 = min(4*x[a1].sc+y[a1].sc,4*y[a1].sc+x[a1].sc);k4 = max(4*x[a1].sc+y[a1].sc,4*y[a1].sc+x[a1].sc);
                        j1 = min(4*x[a2].fs+y[a2].fs,4*y[a2].fs+x[a2].fs);j2 = max(4*x[a2].fs+y[a2].fs,4*y[a2].fs+x[a2].fs);
                        j3 = min(4*x[a2].sc+y[a2].sc,4*y[a2].sc+x[a2].sc);j4 = max(4*x[a2].sc+y[a2].sc,4*y[a2].sc+x[a2].sc);
                        //ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                        //ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                        if((k1 <= 5*x[a3].fs && 5*x[a3].fs <= k2) && (k3 <= 5*x[a3].sc && 5*x[a3].sc <= k4)
                        && (j1 <= 5*y[a3].fs && 5*y[a3].fs <= j2) && (j3 <= 5*y[a3].sc && 5*y[a3].sc <= j4) ) {flag =1;break;}
                    }
                    if(rep2 == 0 && rep3 == 0){
                        ll k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                        ll k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                        ll j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                        ll j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                        if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                        else{
                            ini(cond,a1,a2,a3);
                            continue;
                        }
                        k1 = min(4*x[a1].fs+y[a1].fs,4*y[a1].fs+x[a1].fs);k2 = max(4*x[a1].fs+y[a1].fs,4*y[a1].fs+x[a1].fs);
                        k3 = min(4*x[a1].sc+y[a1].sc,4*y[a1].sc+x[a1].sc);k4 = max(4*x[a1].sc+y[a1].sc,4*y[a1].sc+x[a1].sc);
                        j1 = min(4*x[a2].fs+y[a2].fs,4*y[a2].fs+x[a2].fs);j2 = max(4*x[a2].fs+y[a2].fs,4*y[a2].fs+x[a2].fs);
                        j3 = min(4*x[a2].sc+y[a2].sc,4*y[a2].sc+x[a2].sc);j4 = max(4*x[a2].sc+y[a2].sc,4*y[a2].sc+x[a2].sc);
                        //ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                        //ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                        if((k1 <= 5*y[a3].fs && 5*y[a3].fs <= k2) && (k3 <= 5*y[a3].sc && 5*y[a3].sc <= k4)
                        && (j1 <= 5*x[a3].fs && 5*x[a3].fs <= j2) && (j3 <= 5*x[a3].sc && 5*x[a3].sc <= j4) ) {flag =1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];
ld ep = 1e-15;

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}
bool cmp(pair <ld,ld> a,pair <ld,ld> b){
	if(abs(a.fs - b.fs)< ep && abs(a.sc - b.sc)< ep) return true;
  	else return false;
}
void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(cmp(x[a1],x[a2])){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(cmp(x[a1],y[a2]) ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(cmp(y[a1],x[a2])){
                    cond = 3;
                }
                else if(cmp(y[a1],y[a2])){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));
              	//trace(angulo);
                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(abs(x[a1].fs - y[a1].fs) < ep){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(abs(x[a2].fs - y[a2].fs) < ep){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	/*trace(rep1,rep2,rep3,rep4,a1,a2,a3);
              	trace(e1,e2,e3,p1,p2,p3);
              	trace(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	trace(x[a3].fs,x[a3].sc,y[a3].fs,y[a3].sc);*/
                if((abs(rep1) < ep && abs(rep4) < ep) || (abs(rep2) < ep && abs(rep3) < ep)){
                    if(abs(rep1) < ep && abs(rep4) < ep){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(abs(rep2) <ep && abs(rep3) < ep){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];
ld ep = 1e-9;

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}
bool cmp(pair <ld,ld> a,pair <ld,ld> b){
	if(abs(a.fs - b.fs)< ep && abs(a.sc - b.sc)< ep) return true;
  	else return false;
}
void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(cmp(x[a1],x[a2])){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(cmp(x[a1],y[a2]) ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(cmp(y[a1],x[a2])){
                    cond = 3;
                }
                else if(cmp(y[a1],y[a2])){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));
              	//trace(angulo);
                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(abs(x[a1].fs - y[a1].fs) < ep){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(abs(x[a2].fs - y[a2].fs) < ep){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	/*trace(rep1,rep2,rep3,rep4,a1,a2,a3);
              	trace(e1,e2,e3,p1,p2,p3);
              	trace(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	trace(x[a3].fs,x[a3].sc,y[a3].fs,y[a3].sc);*/
                if((abs(rep1) < ep && abs(rep4) < ep) || (abs(rep2) < ep && abs(rep3) < ep)){
                    if(abs(rep1) < ep && abs(rep4) < ep){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((4*d1 >= d2) && (4*d2 >= d1) && (4*d3 >= d4) && (4*d4) >= d3) {flag = 1; break;}
                    }
                    if(abs(rep2) <ep && abs(rep3) < ep){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((4*d1 >= d2) && (4*d2 >= d1) && (4*d3 >= d4) && (4*d4) >= d3) {flag = 1; break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}

int main(){
    fastio;
    ll tc; cin >> tc;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

        vector <ll> v = {1,2,3};
        ll flag = 0;
        do{
          	//trace(v[0],v[1],v[2]);
          	//if(v[0] == 3 && v[1] == 2 && v[2] == 1)
            ll a1= v[0], a2 = v[1], a3 = v[2];
          	/*if(v[0] == 3 && v[1] == 1 && v[2] == 2){
            	trace(y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc);
            }*/

          	if(y[a1]== y[a2]){
            	swap(x[a2],y[a2]);
            }
          	if(x[a1] == x[a2]){
            	swap(x[a1],y[a1]);
            }
            if(y[a1] != x[a2]) continue;
            ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
            ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
            ld area =  cal_area(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc,y[a2].fs,y[a2].sc);
            //trace(dis1,dis2,area);
          	ld rep = 2*area/(dis1*dis2);
            ld angulo = asin(rep);
          	ld val = acos(-1);
          	//trace(angulo,val/2.0);
            if(angulo > val/2.00) continue;
            ld e1=1,e2,e3;
            ld p1=1,p2,p3;
            if(x[a1].fs == y[a1].fs){
                e1 = 0;
                e2 = 1;
                e3 = -x[a1].fs;
            }
            else{
                ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                e2 = -m1;
                e3 = m1*x[a1].fs - x[a1].sc;
            }
            if(x[a2].fs == y[a2].fs){
                p1 = 0;
                p2 = 1;
                p3 = -x[a1].fs;
            }
            else{
                ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
              	//trace(m2);
                p2 = -m2;
                p3 = m2*x[a2].fs - x[a2].sc;
            }
          	//trace(e1,e2,e3);
          	//trace(p1,p2,p3);
            ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
            ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
            ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
            ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
          	//trace(rep1,rep2,rep3,rep4);
            if((rep1 == 0 && rep4 == 0) || (rep2 == 0 && rep3 == 0)){
                if(rep1 == 0 && rep4 == 0){
                    ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                    ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                    ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                    ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                  	//trace(d1,d2,d3,d4);
                    if((d1/d2 >= 0.25 && d2/d1>= 0.25) && (d3/d4 >= 0.25 && d4/d3 >=0.25)) flag = 1;
                }
                if(rep2 == 0 && rep3 == 0){
                    ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                    ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                    ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                    ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                    if((d1/d2 >= 0.25 && d2/d1>= 0.25) && (d3/d4 >= 0.25 && d4/d3 >=0.25)) flag = 1;
                }
            }
            else continue;
        }while(next_permutation(v.begin(),v.end()));
        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}

int main(){
    fastio;
    ll tc; cin >> tc;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

        vector <ll> v = {1,2,3};
        ll flag = 0;
        do{
          	//trace(v[0],v[1],v[2]);
          	//if(v[0] == 3 && v[1] == 2 && v[2] == 1)
            ll a1= v[0], a2 = v[1], a3 = v[2];
          	/*if(v[0] == 3 && v[1] == 1 && v[2] == 2){
            	trace(y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc);
            }*/

          	if(y[a1]== y[a2]){
            	swap(x[a2],y[a2]);
            }
          	if(x[a1] == x[a2]){
            	swap(x[a1],y[a1]);
            }
            if(y[a1] != x[a2]) continue;
            ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
            ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
            ld area =  cal_area(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc,y[a2].fs,y[a2].sc);
            //trace(dis1,dis2,area);
          	ld rep = 2*area/(dis1*dis2);
            ld angulo = asin(rep);
          	ld val = acos(-1);
          	//trace(angulo,val/2.0);
            if(angulo > val/2.00) continue;
            ld e1=1,e2,e3;
            ld p1=1,p2,p3;
            if(x[a1].fs == y[a1].fs){
                e1 = 0;
                e2 = 1;
                e3 = -x[a1].fs;
            }
            else{
                ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                e2 = -m1;
                e3 = m1*x[a1].fs - x[a1].sc;
            }
            if(x[a2].fs == y[a2].fs){
                p1 = 0;
                p2 = 1;
                p3 = -x[a1].fs;
            }
            else{
                ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
              	//trace(m2);
                p2 = -m2;
                p3 = m2*x[a2].fs - x[a2].sc;
            }
          	//trace(e1,e2,e3);
          	//trace(p1,p2,p3);
            ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
            ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
            ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
            ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
          	//trace(rep1,rep2,rep3,rep4);
            if((rep1 == 0 && rep4 == 0) || (rep2 == 0 && rep3 == 0)){
                if(rep1 == 0 && rep4 == 0){
                    ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                    ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                    ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                    ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                  	//trace(d1,d2,d3,d4);
                    if((d1/d2 >= 0.25 && d2/d1>= 0.25) && (d3/d4 >= 0.25 && d4/d3 >=0.25)) flag = 1;
                }
                if(rep2 == 0 && rep3 == 0){
                    ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                    ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                    ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                    ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                    if((d1/d2 >= 0.25 && d2/d1>= 0.25) && (d3/d4 >= 0.25 && d4/d3 >=0.25)) flag = 1;
                }
            }
            else continue;
        }while(next_permutation(v.begin(),v.end()));
        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}

void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(x[a1] == x[a2]){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(x[a1] == y[a2]){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(y[a1] == x[a2]){
                    cond = 3;
                }
                else if(y[a1] == y[a2]){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));

                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(x[a1].fs == y[a1].fs){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(x[a2].fs == y[a2].fs){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
                if((rep1 == 0 && rep4 == 0) || (rep2 == 0 && rep3 == 0)){
                    if(rep1 == 0 && rep4 == 0){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(rep2 == 0 && rep3 == 0){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}
bool cmp(pair <ld,ld> a,pair <ld,ld> b){
	if(abs(a.fs - b.fs)< 1e-9 && abs(a.sc - b.sc)< 1e-9 ) return true;
  	else return false;
}
void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(cmp(x[a1],x[a2])){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(cmp(x[a1],y[a2]) ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(cmp(y[a1],x[a2])){
                    cond = 3;
                }
                else if(cmp(y[a1],y[a2])){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));
              	//trace(angulo);
                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(abs(x[a1].fs - y[a1].fs) < 1e-9){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(abs(x[a2].fs - y[a2].fs) < 1e-9){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	/*trace(rep1,rep2,rep3,rep4,a1,a2,a3);
              	trace(e1,e2,e3,p1,p2,p3);
              	trace(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	trace(x[a3].fs,x[a3].sc,y[a3].fs,y[a3].sc);*/
                if((abs(rep1) < 1e-18 && abs(rep4) < 1e-18) || (abs(rep2) < 1e-18 && abs(rep3) < 1e-18)){
                    if(abs(rep1) < 1e-18 && abs(rep4) < 1e-18){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(abs(rep2) < 1e-18 && abs(rep3) < 1e-18){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}
bool cmp(pair <ld,ld> a,pair <ld,ld> b){
	if(abs(a.fs - b.fs)< 1e-9 && abs(a.sc - b.sc)< 1e-9 ) return true;
  	else return false;
}
void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(cmp(x[a1],x[a2])){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(cmp(x[a1],y[a2]) ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(cmp(y[a1],x[a2])){
                    cond = 3;
                }
                else if(cmp(y[a1],y[a2])){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));
              	//trace(angulo);
                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(abs(x[a1].fs - y[a1].fs) < 1e-9){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(abs(x[a2].fs - y[a2].fs) < 1e-9){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	/*trace(rep1,rep2,rep3,rep4,a1,a2,a3);
              	trace(e1,e2,e3,p1,p2,p3);
              	trace(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	trace(x[a3].fs,x[a3].sc,y[a3].fs,y[a3].sc);*/
                if((abs(rep1) < 1e-9 && abs(rep4) < 1e-9) || (abs(rep2) < 1e-9 && abs(rep3) < 1e-9)){
                    if(abs(rep1) < 1e-9 && abs(rep4) < 1e-9){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(abs(rep2) < 1e-9 && abs(rep3) < 1e-9){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}

void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(x[a1] == x[a2]){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(x[a1] == y[a2]){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(y[a1] == x[a2]){
                    cond = 3;
                }
                else if(y[a1] == y[a2]){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));

                ld val = acos(-1);
                if(angulo > val/2.00) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(x[a1].fs == y[a1].fs){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(x[a2].fs == y[a2].fs){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
                if((rep1 == 0 && rep4 == 0) || (rep2 == 0 && rep3 == 0)){
                    if(rep1 == 0 && rep4 == 0){
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) flag = 1;
                    }
                    if(rep2 == 0 && rep3 == 0){
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) flag = 1;
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}
bool cmp(pair <ld,ld> a,pair <ld,ld> b){
	if(abs(a.fs - b.fs)< 1e-10 && abs(a.sc - b.sc)< 1e-10 ) return true;
  	else return false;
}
void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(cmp(x[a1],x[a2])){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(cmp(x[a1],y[a2]) ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(cmp(y[a1],x[a2])){
                    cond = 3;
                }
                else if(cmp(y[a1],y[a2])){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));
              	//trace(angulo);
                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(abs(x[a1].fs - y[a1].fs) < 1e-10){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(abs(x[a2].fs - y[a2].fs) < 1e-10){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	/*trace(rep1,rep2,rep3,rep4,a1,a2,a3);
              	trace(e1,e2,e3,p1,p2,p3);
              	trace(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	trace(x[a3].fs,x[a3].sc,y[a3].fs,y[a3].sc);*/
                if((abs(rep1) < 1e-10 && abs(rep4) < 1e-10) || (abs(rep2) < 1e-10 && abs(rep3) < 1e-10)){
                    if(abs(rep1) < 1e-10 && abs(rep4) < 1e-10){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(abs(rep2) < 1e-10 && abs(rep3) < 1e-10){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}

int main(){
    fastio;
    ll tc; cin >> tc;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

        vector <ll> v = {1,2,3};
        ll flag = 0;
        do{
          	//trace(v[0],v[1],v[2]);
          	//if(v[0] == 3 && v[1] == 2 && v[2] == 1)
            ll a1= v[0], a2 = v[1], a3 = v[2];
          	/*if(v[0] == 3 && v[1] == 1 && v[2] == 2){
            	trace(y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc);
            }*/
            if(y[a1] != x[a2]) continue;
            ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
            ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
            ld area =  cal_area(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc,y[a2].fs,y[a2].sc);
            //trace(dis1,dis2,area);
          	ld rep = 2*area/(dis1*dis2);
            ld angulo = asin(rep);
          	ld val = acos(-1);
          	//if(v[0] == 3 && v[1] == 1 && v[2] == 2) trace(angulo,val/2.0);
            if(angulo > val/2.00) continue;
            ld e1=1,e2,e3;
            ld p1=1,p2,p3;
            if(x[a1].fs == y[a1].fs){
                e1 = 0;
                e2 = 1;
                e3 = -x[a1].fs;
            }
            else{
                ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                e2 = -m1;
                e3 = m1*x[a1].fs - x[a1].sc;
            }
            if(x[a2].fs == y[a2].fs){
                p1 = 0;
                p2 = 1;
                p3 = -x[a1].fs;
            }
            else{
                ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
              	//trace(m2);
                p2 = -m2;
                p3 = m2*x[a2].fs - x[a2].sc;
            }
          	//trace(e1,e2,e3);
          	//trace(p1,p2,p3);
            ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
            ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
            ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
            ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
          	//trace(rep1,rep2,rep3,rep4);
            if((rep1 == 0 && rep4 == 0) || (rep2 == 0 && rep3 == 0)){
                if(rep1 == 0 && rep4 == 0){
                    ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                    ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                    ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                    ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                  	//trace(d1,d2,d3,d4);
                    if(d1/d2 >= 0.25 && d3/d4 >= 0.25) flag = 1;
                }
                if(rep2 == 0 && rep3 == 0){
                    ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                    ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                    ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                    ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                    if(d1/d2 >= 0.25 && d3/d4 >= 0.25) flag = 1;
                }
            }
            else continue;
        }while(next_permutation(v.begin(),v.end()));
        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];
ld ep = 1e-3;
ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}
bool cmp(pair <ld,ld> a,pair <ld,ld> b){
	if(abs(a.fs - b.fs)< ep && abs(a.sc - b.sc)< ep) return true;
  	else return false;
}
void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(cmp(x[a1],x[a2])){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(cmp(x[a1],y[a2]) ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(cmp(y[a1],x[a2])){
                    cond = 3;
                }
                else if(cmp(y[a1],y[a2])){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));
              	//trace(angulo);
                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(abs(x[a1].fs - y[a1].fs) < ep){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(abs(x[a2].fs - y[a2].fs) < ep){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	/*trace(rep1,rep2,rep3,rep4,a1,a2,a3);
              	trace(e1,e2,e3,p1,p2,p3);
              	trace(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	trace(x[a3].fs,x[a3].sc,y[a3].fs,y[a3].sc);*/
                if((abs(rep1) < ep && abs(rep4) < ep) || (abs(rep2) < ep && abs(rep3) < ep)){
                    if(abs(rep1) < ep && abs(rep4) < ep){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(abs(rep2) <ep && abs(rep3) < ep){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}
bool cmp(pair <ld,ld> a,pair <ld,ld> b){
	if(abs(a.fs - b.fs)< 1e-6 && abs(a.sc - b.sc)< 1e-6 ) return true;
  	else return false;
}
void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
  	//cout<<point({1,-1},{0,-1})<<endl;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(cmp(x[a1],x[a2])){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(cmp(x[a1],y[a2]) ){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(cmp(y[a1],x[a2])){
                    cond = 3;
                }
                else if(cmp(y[a1],y[a2])){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));
              	//trace(angulo);
                ld val = acos(-1);
                if(angulo > val/2.00 ) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(abs(x[a1].fs - y[a1].fs) < 1e-6){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(abs(x[a2].fs - y[a2].fs) < 1e-6){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
              	/*trace(rep1,rep2,rep3,rep4,a1,a2,a3);
              	trace(e1,e2,e3,p1,p2,p3);
              	trace(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
              	trace(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	trace(x[a3].fs,x[a3].sc,y[a3].fs,y[a3].sc);*/
                if((abs(rep1) < 1e-6 && abs(rep4) < 1e-6) || (abs(rep2) < 1e-6 && abs(rep3) < 1e-6)){
                    if(abs(rep1) < 1e-6 && abs(rep4) < 1e-6){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= x[a3].fs && x[a3].fs <= k2) && (k3 <= x[a3].sc && x[a3].sc <= k4)
                        && (j1 <= y[a3].fs && y[a3].fs <= j2) && (j3 <= y[a3].sc && y[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(abs(rep2) < 1e-6 && abs(rep3) < 1e-6){
                      	ld k1 = min(x[a1].fs,y[a1].fs),k2 = max(x[a1].fs,y[a1].fs);
                      	ld k3 = min(x[a1].sc,y[a1].sc),k4 = max(x[a1].sc,y[a1].sc);
                      	ld j1 = min(x[a2].fs,y[a2].fs),j2 = max(x[a2].fs,y[a2].fs);
                      	ld j3 = min(x[a2].sc,y[a2].sc),j4 = max(x[a2].sc,y[a2].sc);
                      	if((k1 <= y[a3].fs && y[a3].fs <= k2) && (k3 <= y[a3].sc && y[a3].sc <= k4)
                        && (j1 <= x[a3].fs && x[a3].fs <= j2) && (j3 <= x[a3].sc && x[a3].sc <= j4) ) ll ga = 1;
                      	else{
                        	ini(cond,a1,a2,a3);
                          	continue;
                        }
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}

void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(x[a1] == x[a2]){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(x[a1] == y[a2]){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(y[a1] == x[a2]){
                    cond = 3;
                }
                else if(y[a1] == y[a2]){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));

                ld val = acos(-1);
                if(angulo > val/2.00) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(x[a1].fs == y[a1].fs){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(x[a2].fs == y[a2].fs){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
                if((rep1 == 0 && rep4 == 0) || (rep2 == 0 && rep3 == 0)){
                    if(rep1 == 0 && rep4 == 0){
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1; break;}
                    }
                    if(rep2 == 0 && rep3 == 0){
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if((d1/d2 >= 0.25) && (d2/d1 >= 0.25) && (d3/d4 >= 0.25) && (d4/d3) >= 0.25) {flag = 1;break;}
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}


//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ )
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef long double ld;
using namespace std;
const ll inf=1e10+6;
const ll MOD=1e9+7;
const ll mod=998244353;
// ac cmtr;
const int MX = 1e6+5;
const int LG = 25;

#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

//---------------------------

pair <ld,ld> x[MX],y[MX];

ld point(pair <ld,ld> u,pair <ld,ld> v){
	return u.fs*v.fs + u.sc*v.sc;
}
ld dis(ld a,ld b,ld x, ld y){
    return sqrt((a-x)*(a-x) + (b-y)*(b-y));
}
ld cal_area(ld a,ld b,ld c,ld d,ld e,ld f){
    ld ans = abs( (b*c +d*e + f*a) - (a*d+c*f+e*b) )/2;
    return ans;
}

void ini(ll cond,ll a1,ll a2,ll a3){
    if(cond == 1){
        swap(x[a1],y[a1]);
    }
    else if(cond == 2){
        swap(x[a1],y[a1]);
        swap(x[a2],y[a2]);
    }
    else if(cond == 4){
        swap(x[a2],y[a2]);
    }
}

int main(){
    fastio;
    ll tc; cin >> tc;
    while(tc--){
        cin >> x[1].fs >> x[1].sc >> y[1].fs >> y[1].sc;
        cin >> x[2].fs >> x[2].sc >> y[2].fs >> y[2].sc;
        cin >> x[3].fs >> x[3].sc >> y[3].fs >> y[3].sc;

      	//x[1].fs/= 1000.00;

        ll flag = 0;
        for(int i = 1 ; i<= 3; i++){
            for(int j = 1; j <= 3; j++){
                if(i == j) continue;
                ll a1 = i,a2 = j,a3;
                if((a1 == 1 && a2 ==2) || (a1 == 2 && a2 ==1)) a3 = 3;
                if((a1 == 3 && a2 ==2) || (a1 == 2 && a2 ==3)) a3 = 1;
                if((a1 == 1 && a2 ==3) || (a1 == 3 && a2 ==1)) a3 = 2;

                ll cond = 0;
                if(x[a1] == x[a2]){
                    swap(x[a1],y[a1]);
                    cond = 1;
                }
                else if(x[a1] == y[a2]){
                    swap(x[a1],y[a1]);
                    swap(x[a2],y[a2]);
                    cond = 2;
                }
                else if(y[a1] == x[a2]){
                    cond = 3;
                }
                else if(y[a1] == y[a2]){
                    swap(x[a2],y[a2]);
                    cond = 4;
                }
                else continue;
                //if((y[a1] != x[a2]) && )  continue;
            	pair <ld,ld > u= {x[a1].fs-y[a1].fs,x[a1].sc-y[a1].sc};
              	pair <ld,ld > v= {y[a2].fs-x[a2].fs,y[a2].sc-x[a2].sc};
              	ld aux = point(u,v);

                ld dis1 = dis(x[a1].fs,x[a1].sc,y[a1].fs,y[a1].sc);
                ld dis2 = dis(x[a2].fs,x[a2].sc,y[a2].fs,y[a2].sc);
              	ld angulo = acos(aux/(dis1*dis2));

                ld val = acos(-1);
                if(angulo > val/2.00) {
                    ini(cond,a1,a2,a3);
                    continue;
                }
                ld e1=1,e2,e3;
                ld p1=1,p2,p3;
                if(x[a1].fs == y[a1].fs){
                    e1 = 0.00;
                    e2 = 1.00;
                    e3 = -x[a1].fs;
                }
                else{
                    ld m1 = (y[a1].sc - x[a1].sc)/(y[a1].fs-x[a1].fs);
                    e2 = -m1;
                    e3 = m1*x[a1].fs - x[a1].sc;
                }
                if(x[a2].fs == y[a2].fs){
                    p1 = 0.00;
                    p2 = 1.00;
                    p3 = -x[a1].fs;
                }
                else{
                    ld m2 = (y[a2].sc - x[a2].sc)/(y[a2].fs-x[a2].fs);
                    //trace(m2);
                    p2 = -m2;
                    p3 = m2*x[a2].fs - x[a2].sc;
                }
                ld rep1 = e1*x[a3].sc + e2*x[a3].fs + e3;
                ld rep2 = e1*y[a3].sc + e2*y[a3].fs + e3;
                ld rep3 = p1*x[a3].sc + p2*x[a3].fs + p3;
                ld rep4 = p1*y[a3].sc + p2*y[a3].fs + p3;
                if((rep1 == 0 && rep4 == 0) || (rep2 == 0 && rep3 == 0)){
                    if(rep1 == 0 && rep4 == 0){
                        ld d1 = dis(x[a1].fs,x[a1].sc,x[a3].fs,x[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,x[a3].fs,x[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,y[a3].fs,y[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,y[a3].fs,y[a3].sc);
                        if(d1/d2 >= 0.25 && d3/d4 >= 0.25) flag = 1;
                    }
                    if(rep2 == 0 && rep3 == 0){
                        ld d1 = dis(x[a1].fs,x[a1].sc,y[a3].fs,y[a3].sc);
                        ld d2 = dis(y[a1].fs,y[a1].sc,y[a3].fs,y[a3].sc);
                        ld d3 = dis(x[a2].fs,x[a2].sc,x[a3].fs,x[a3].sc);
                        ld d4 = dis(y[a2].fs,y[a2].sc,x[a3].fs,x[a3].sc);
                        if(d1/d2 >= 0.25 && d3/d4 >= 0.25) flag = 1;
                    }
                }
                else{
                    ini(cond,a1,a2,a3);
                    continue;
                }
              	ini(cond,a1,a2,a3);
            }
        }

        if(flag == 1) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;

    }

}