Start

2019-01-07 13:28 UTC

test3

End

2019-01-07 13:48 UTC
The end is near!
Contest is over.
Not yet started.
Contest is starting in -230 days 15:24:56

Time elapsed

0:20:00

Time remaining

0:00:00

Problem A
Line Segment Distance

Input

The first line of input contains an integer $n$ ($n \leq 10000$) giving the number of test cases. Then follow $n$ lines each containing 8 integers $x_1\ y_1\ x_2\ y_2\ x_3\ y_3\ x_4\ y_4$, indicating a line segment from $(x_1, y_1)$ to $(x_2, y_2)$, and a line segment from $(x_3, y_3)$ to $(x_4, y_4)$. Coordinates have absolute value at most 10000.

Output

For each test case, output the distance between the two line segments with 2 decimals of precision.

Sample Input 1 Sample Output 1
5
-10 0 10 0 0 -10 0 10
-10 0 10 0 -5 0 5 0
1 1 1 1 1 1 2 1
1 1 1 1 2 1 2 1
1871 5789 216 -517 189 -1518 3851 1895
0.00
0.00
0.00
1.00
713.86