409248: GYM103466 K Triangle

Memory Limit:512 MB Time Limit:8 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Triangletime limit per test8 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

One day, ABC and DD found a triangular wheat field, and they decide to cut it into two pieces with the same area with a segment. Because of various reasons, one of the endpoints of the division line is fixed at $$$(p_x, p_y)$$$. Now you are asked to find the other endpoint of the segment.

If the given endpoint does not lie on the boundary of the wheat field, the problem should be regarded as invalid. The other endpoint required should also locate on the boundary.

Input

The input provides several test cases and the first line of the input contains a single integer $$$T~(1 \le T \le 10^6)$$$ indicating the number of cases.

For each test case, eight integers $$$x_1,y_1,x_2,y_2,x_3,y_3,p_x$$$ and $$$p_y$$$ are given in a line, where $$$(x_1,y_1),(x_2,y_2)$$$ and $$$(x_3,y_3)$$$ describe the coordinates of vertices for the given triangle wheat field which are guaranteed to be not colinear, and $$$(p_x,p_y)$$$ is the given endpont of the segment. All coordinates are integers in the range $$$[0,10^5]$$$.

Output

For each test case, output the coordinate of the other endpoint of the division segment, or output the number -1 if the problem, in this case, is invalid.

Formally, if your answer is $$$a$$$ and the jury's answer is $$$b$$$, then your answer will be considered correct if and only if $$$\frac{|a - b|}{\max\{1, |b|\}} \le 10^{-6}$$$.

ExampleInput
2
0 0 1 1 1 0 1 0
0 0 1 1 1 0 2 0
Output
0.500000000000 0.500000000000
-1

加入题单

算法标签: