Big Island and Tiny Island are two neighboring islands in the Little Sea. The king of Big Island wants to conquer Tiny island to appease his fragile ego. However, the wind blows strong in Little Sea and the ships are slow and light. Therefore, reaching Tiny island may be difficult and time consuming; in some cases, even impossible. Furthermore, the weather is volatile so the wind direction is hard to predict. Thus the king would like to make plans in advance and find the minimum time to reach Tiny Island from Big Island given various wind velocities.
Big Island and Tiny Island can be described as two non-intersecting convex polygons of n and m vertices respectively. The king will ask you q queries. In each query, you will be given a vector ${ \vec{w} = (w_x . w_y) }$ representing the wind velocity and an integer s, the maximum speed of Big Island ships. The ships can choose to depart from any point of Big Island and choose to move in any direction they like. If the ships’ own velocity is described by ${\vec{v}}$, then ${|\vec{v}|}$ must not be greater than s and the ships’ resulting velocity will be ${\vec{v} + \vec{w}}$.
Your task is to determine for each query, if it is possible to reach any point of Tiny Island. If so, you also need to find the minimum time needed.
Input
The first line contains the number of test cases T.
First line of each test case has two integers n and m. Each of the next n lines contain two integers x and y, the coordinates of a vertex of Big Island. Each of the next m lines contain two integers x and y, the coordinates of a vertex of Tiny Island. For each polygon, vertices are given in counter-clockwise order.
The next line contains a single integer q. Each of the next q lines contain three integers, wx, wy and s.
Constraints
- 1 ≤ T ≤ 1111
- 3 ≤ n, m ≤ 105
- The sum of n + m over all test cases doesn’t exceed 2 x 105
- -109 ≤ x, y ≤ 109
- -109 ≤ wx, wy ≤ 109
- 0 ≤ s ≤ 109
- 1 ≤ q ≤ 20000
- Sum of q over all cases does not exceed 20000
- Input is generated such that answer for any query will not exceed 109.
Output
For each query output a single line.
- If it is not possible to reach any point of Tiny Island, print -1.
- Otherwise print a single real number, the minimum time needed to reach any point of Tiny Island.
Your answer will be considered correct if its absolute or relative error doesn't exceed 10-6. Namely, if your answer is a, and the jury's answer is b, then your answer is considered correct, if ${ |a-b| \over max(1, |b|) }$ ${ \le 10^{-6} }$.
Sample
Sample Input | Sample Output |
---|---|
1 4 4 0 0 1 0 1 1 0 1 2 2 3 2 3 3 2 3 2 1 1 1 -1 -1 1 | 0.5857864376 -1 |