//Tencent_0912_2
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static class Point{
public int x;
public int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public double getDis(Point p){
return Math.pow((this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y), 0.5);
}
}
public static void main(String[] args) {
Point[] ps = new Point[4];
Scanner in = new Scanner(System.in);
while(in.hasNext()){
String res = "";
int n = in.nextInt();
while(n-->0){
int[] locas = new int[8];
for(int i=0; i<8; i++){
locas[i] = in.nextInt();
}
for(int i=0; i<4; i++){
ps[i] = new Point(locas[i], locas[i+4]);
}
res += judge(ps) + "\n";
}
System.out.print(res);
}
}
private static String judge(Point[] ps) {
double[] dis = new double[6];
dis[0] = ps[0].getDis(ps[1]);
dis[1] = ps[0].getDis(ps[2]);
dis[2] = ps[0].getDis(ps[3]);
dis[3] = ps[1].getDis(ps[2]);
dis[4] = ps[1].getDis(ps[3]);
dis[5] = ps[2].getDis(ps[3]);
Arrays.sort(dis);
int a = 0, b = 0;
for(int i=0; i<6; i++){
if(dis[i] == dis[0]) a++;
if(dis[i] == dis[5]) b++;
}
if((a==4 && b==2) || (a==2 && b==4)) return "YES";
return "NO";
}
}