#C11826. Determine if Four Points Form a Rectangle

    ID: 41185 Type: Default 1000ms 256MiB

Determine if Four Points Form a Rectangle

Determine if Four Points Form a Rectangle

Given four points in a 2D plane, determine whether they form the vertices of a rectangle.

A quadrilateral is a rectangle if all its angles are right angles. Equivalently, for four points \(P_1(x_1,y_1)\), \(P_2(x_2,y_2)\), \(P_3(x_3,y_3)\), and \(P_4(x_4,y_4)\), if the center \(C\) defined as \(C = \left(\frac{x_1+x_2+x_3+x_4}{4},\;\frac{y_1+y_2+y_3+y_4}{4}\right)\) is equidistant from every vertex (with a positive distance), then the points form a rectangle.

inputFormat

The first line contains an integer \(T\) (1 ≤ \(T\) ≤ 100), representing the number of test cases. For each test case, the next four lines each contain two space-separated integers representing the \(x\) and \(y\) coordinates of a point.

outputFormat

For each test case, output a single line containing YES if the four points form a rectangle, or NO otherwise.

## sample
3
0 0
1 0
1 1
0 1
-1000 -1000
1000 -1000
1000 1000
-1000 1000
0 0
1 2
3 1
2 3
YES

YES NO

</p>