Gondor has circular gold mines with IDs from to containing some gold. Each mine’s center can be located by a 2D coordinate.
Ri, the miner, lives in a place in Gondor that a coordinate on a 2D plane can locate. She can dig mines that only cover her place. In other words, she can dig a mine if her location lies inside or on the boundary of that mine.
Even though it would have been better to dig all the mines, she unable to move much for sickness and can only dig one mine at most. So, she wants to dig the mine that contains the most amount of gold. Help her to find the most suitable one.
The first line of the input will consist of an integer the number of testcases. The description of each testcase follows:
The first line of the testcase will consist of an integer the number of gold mines.
Next lines will contain four integers, the coordinates of the center of the mines, the radius of the mines, and amount of gold in each mine respectively.
Next line will contain an integer number of queries.
Each query will contain two integers in a line, coordinates of Ri’s location.
Additional constraints for the queries: Either or or both for all .
Moreover, you can assume that the sum of and the sum of over all testcases will not exceed respectively.
For each query, print the ID of the mine that Ri will dig. If there are multiple mines, print the minimum ID. If no mines cover Ri’s place, print .
Input | Output |
---|---|
1 3 0 0 1 3 -1 0 1 10 -1 -1 2 9 3 -1 -2 -1 1 -1 2 | 3 2 -1 |
See the image to understand the sample case. Here, the dots are the center of the circles and the dots are the places of Ri. |