Symmetry: Closure

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

A point set SS is symmetric about a line \ell if and only if there exists sSs' \in S satisfying that ss' and ss are symmetric about the line \ell for all sSs \in S.

Let us denote the distance between two points aa and bb as d(a,b)d(a,b). The distance between two non-empty point sets AA and BB is \inf \left\\{d(a,b) : a \in A, \\, b \in B \right\\}. The infimum of a non-empty real number set SS is the maximum value of xx which satisfies xsx \le s for all sSs \in S.

Lines _1,_2,,_n\ell\_1, \ell\_2, \ldots, \ell\_n are given, where two or more lines may coincide. For a point ss, define C(s)C(s) as the intersection of all sets SS satisfying sSs \in S such that SS is symmetric about _i\ell\_i for all i=1,2,,ni = 1, 2, \ldots, n.

There are qq queries. For each query, given two points AA and BB, find the distance between C(A)C(A) and C(B)C(B).

입력

There are multiple test cases. The first line of input contains an integer TT (1T1051\le T\le 10^5), the number of test cases. For each test case:

The first line contains an integer nn and qq (1n,q1051\le n, q\le 10^5): the number of lines and the number of points.

The ii-th of the following nn lines contains four integers x_P_ix\_{P\_i}, y_P_iy\_{P\_i}, x_Q_ix\_{Q\_i}, and y_Q_iy\_{Q\_i}: the coordinates of P_iP\_i and Q_iQ\_i such that _i\ell\_i passes through P_iP\_i and Q_iQ\_i. It is guaranteed that x_P_ix_Q_ix\_{P\_i} \ne x\_{Q\_i} or y_P_iy_Q_iy\_{P\_i} \ne y\_{Q\_i}. Any two lines may coincide.

The ii-th of the following qq lines contains four integers x_A_ix\_{A\_i}, y_A_iy\_{A\_i}, x_B_ix\_{B\_i}, and y_B_iy\_{B\_i}: the coordinates of A_iA\_i and B_iB\_i.

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

It is guaranteed that both the sum of nn and the sum of qq over all test cases do not exceed 10510^5.

출력

For each test case:

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

The distance you output will be considered correct if the relative error or absolute error to the jury does not exceed 10910^{-9}.