#P7700. [2019年杭电多校]geometric problem

[2019年杭电多校]geometric problem

geometric problem

Problem Description

There are six points ABMNXYABMNXY in a two-dimensional plane. As shown in the figure below, ABNMABNM and XYNMXYNM are both in convex quadrilateral shapes, and their intersection area is 00. You are also given two lines L1L1 and L2L2. You have to choose one point on each line (for example, SS on L1L1 and TT on L2L2) so that the area of ABSABS, MSNTMSNT, and XYTXYT are at the same size. Moreover, SS should lie within or be on the border of ABNMABNM, and TT should lie within or be on the border of XYNMXYNM. Please output the positions of SS and TT that you choose!

Input

The first line contains an integer TT indicating the number of test cases. Each test case consists of three lines. The first line contains 1212 integers, $A_x, A_y, B_x, B_y, M_x, M_y, N_x, N_y, X_x, X_y, Y_x, Y_y$, denoting the xx and yy coordinates of points A,B,M,N,X,YA,B,M,N,X,Y. The second line contains 44 integers, L11,x,L11,y,L12,xL1_{1,x}, L1_{1,y}, L1_{2,x}, and L12,yL1_{2,y}, denoting two distinct points on L1L1. The third line also contains 44 integers, L21,x,L21,y,L22,xL2_{1,x}, L2_{1,y}, L2_{2,x}, and L22,yL2_{2,y}, denoting two distinct points on L2L2.

  • 1T201 \le T \le 20
  • coordinates are in the range [0,514][0, 514]
  • L11L12L1_1 \neq L1_2, L21L22L2_1 \neq L2_2

Output

For each test case output 44 numbers in a single line, Sx,Sy,Tx,TyS_x, S_y, T_x, T_y, denoting the two chosen points. If there are multiple solutions, output the one with the smallest SxS_x. If there are still multiple solutions, output the one with the smallest SyS_y, and then the smallest TxT_x, and then the smallest TyT_y. Otherwise, if there are no solution, output "-1" (without quotes) in one line. A solution with an absolute error at most 10610^{-6} will be accepted.

Sample Input

1

0 10 0 0 5 10 5 0 10 10 10 0

0 0 5 10

5 0 10 10

Sample Output

3.333333333333 6.666666666667 6.666666666667 3.333333333333

Source

2019 Multi-University Training Contest 5