#1418. Amazing spacecraft
Amazing spacecraft
On this day, Sonetto purchased her first spacecraft (which can be considered as a convex polygon) and eagerly began to operate it. This spacecraft had a touch screen interface where the user could click on a position, and the spacecraft would instantly teleport to that location. However, since Sonetto bought a smuggled spacecraft, after Sonetto clicks on a location, the system randomly selects a point within a circle centered at Sonetto’s clicked position with a radius of , and the spacecraft teleport to that point.On this day, there was a Mr.Cookie’s spacecraft parked in the vicinity, which can also be seen as a convex polygon.
Now, given the position where Sonetto clicked on the screen, you are asked to calculate the probability of Sonetto's spacecraft colliding with Mr.Cookie’s spacecraft parked in the area.
Because the space where Sonetto is located is a rather mysterious space, Sonetto’s spacecraft may initially intersect with Mr.Cookie’s spacecraft. However, we don’t need to be concerned about Sonetto’s initial position. We only need to focus on whether the position of her spacecraft after the instant teleportation will collide with Mr.Cookie’s spacecraft.
To be more specific, you are given two convex polygons and , and a circle (centered at point with radius ). You need to determine the probability of randomly selecting a point within the circle , such that when the convex polygon moves along the vector ( is the origin point (0,0)), it transforms into a new convex polygon , and intersects with (intersection implies that there exists a point such that and ).
Input
The input consists of multiple test cases. The first line contains a single integer () — the number of test cases. Description of the test cases follows.
The second line contains a integer (), denoting the number of vertices of the convex polygons .
Then follows lines, each line contains two integers , (), denoting the th point of the convex polygon . The points are given in counter-clockwise order.
The next line contains a integer (), denoting the number of vertices of the convex polygons .
Then follows lines, each line contains two integers , (), denoting the th point of the convex polygon . The points are given in counter-clockwise order.
The last line contains three integers , and ,denoting the position of the center of the circle and the radius of the circle. ()
The data guarantees that the sum of will not exceed
The data guarantees that the sum of will not exceed
Output
For each test case print a single floating-point number denoting the probability of intersects with .(keep 4 decimal places)
Example
2
5
0 -2
4 -1
4 0
1 1
0 0
4
0 -2
3 -1
2 1
1 0
-2 -2 3
4
-2 0
-1 -2
1 2
-1 2
3
2 0
5 1
3 1
1 -3 4
0.5247
0.1185
Limitation
Time limit: 3 seconds
Memory limit: 128 megabytes