import java.awt.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int count = Integer.parseInt(br.readLine());
for(int i = 0; i < count; i++) {
ArrayList<Point> points = new ArrayList<Point>();
ArrayList<Double> lengths = new ArrayList<Double>();
for(int j = 0; j < 4; j++) {//좌표 추가
String[] line = br.readLine().split(" ");
points.add(new Point(Integer.parseInt(line[0]), Integer.parseInt(line[1])));
}
for(int j = 0; j<4;j++){
for(int k = j+1 ; k<4;k++){
double length = 0;
length = Math.sqrt(Math.pow(points.get(j).x - points.get(k).x,2) + Math.pow(points.get(j).y - points.get(k).y,2));
lengths.add(length);
}
}
Collections.sort(lengths);
Collections.reverse(lengths);
if(Objects.equals(lengths.get(0), lengths.get(1)) && Objects.equals(lengths.get(2), lengths.get(3)) && Objects.equals(lengths.get(2), lengths.get(4)) && Objects.equals(lengths.get(2), lengths.get(5)) ){
bw.write(String.valueOf(1));
bw.newLine();
}else{
bw.write(String.valueOf(0));
bw.newLine();
}
}
bw.flush();
br.close();
bw.close();
}
}
댓글 영역