Symmetry: Closure
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

A point set S is symmetric about a line l if and only if there exists satisfying that s' and s are symmetric about the line l for all .

Denoting the distance between two points a and b as d(a,b). The distance between two non-empty point sets A and B is . The infimum of a non-empty real number set S is the maximum value of x which satisfies for all .

n lines l_1, l_2, , l_n are given, where two lines may coincide. For a point s, define C(s) as the intersection of all sets S satisfying and S is symmetric about l_i for all , 2, , n. There are q queries. For each query, given two points A and B, find the distance between C(A) and C(B).

输入描述:

There are multiple test cases. The first line of input contains an integer T (), the number of test cases. For each test case:

The first line contains an integer n and q (, ) -- the number of lines and the number of points.

The i-th of the following n lines contains four integers , , and -- the coordinates of P_i and Q_i such that l_i passes through P_i and Q_i. It is guaranteed that or . Two lines may coincide.

The i-th of the following q lines contains four integers , , and -- the coordinates of A_i and B_i.

It is guaranteed that the absolute value of all coordinates in the input does not exceed .

It is guaranteed that the sum of n and the sum of q over all test cases does not exceed .

输出描述:

For each test case:

For each query, output the distance between C(A) and C(B).

The distance you output is correct if the relative error or absolute error to the jury does not exceed .
示例1

输入

复制
4
1 1
0 0 1 0
-1 -2 2 1
2 1
0 0 1 0
0 0 0 1
-1 -2 2 1
3 1
0 0 1 0
0 0 0 1
0 0 1 1
-1 -2 2 1
3 1
0 0 1 0
0 0 0 1
0 0 1 2
-1 -2 2 1

输出

复制
3.162277660168
1.414213562373
0.000000000000
0.000000000000
示例2

输入

复制
5
1 1
-8 1 -8 10
-7 -5 -4 -6
2 2
-1 -10 -1 -8
10 9 9 10
2 10 -10 5
-4 4 -3 -3
3 1
-5 -10 -5 6
6 10 8 8
7 -2 4 -5
0 -9 -6 -3
3 3
9 8 10 7
1 5 -9 5
4 -2 -3 -9
6 6 -6 -8
2 -7 10 -3
3 -8 8 -9
1 3
10 -9 10 -7
-2 -7 -2 6
-2 9 -9 2
-6 -7 -7 -9

输出

复制
3.162277660168
7.810249675907
7.071067811865
7.211102550928
0.000000000000
0.000000000000
0.000000000000
13.000000000000
9.899494936612
2.236067977500