#P9795. Amazing spacecraft

Amazing spacecraft

Amazing spacecraft

Problem Description

On this day, SonettoSonetto 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 SonettoSonetto bought a smuggled spacecraft, after SonettoSonetto clicks on a location, the system randomly selects a point within a circle centered at SonettosSonetto's clicked position with a radius of RR, and the spacecraft teleport to that point.On this day, there was a Mr.CookiesMr.Cookie's spacecraft parked in the vicinity, which can also be seen as a convex polygon. Now, given the position where SonettoSonetto clicked on the screen, you are asked to calculate the probability of SonettosSonetto's spacecraft colliding with Mr.CookiesMr.Cookie's spacecraft parked in the area. Because the space where SonettoSonetto is located is a rather mysterious space, SonettosSonetto's spacecraft may initially intersect with Mr.CookiesMr.Cookie's spacecraft. However, we don't need to be concerned about SonettosSonetto's initial position. We only need to focus on whether the position of her spacecraft after the instant teleportation will collide with Mr.CookiesMr.Cookie's spacecraft. To be more specific, you are given two convex polygons AA and BB, and a circle PP (centered at point XX with radius RR). You need to determine the probability of randomly selecting a point SS within the circle PP, such that when the convex polygon AA moves along the vector OS\vec{OS}(OO is the origin point (0,0)), it transforms into a new convex polygon AA', and AA' intersects with BB (intersection implies that there exists a point ww such that wAw \in A' and wBw \in B).

Input

The input consists of multiple test cases. The first line contains a single integer t(1t1200)t(1≤t≤1200) — the number of test cases. Description of the test cases follows. The second line contains a integer nn (3n300003≤n≤30000), denoting the number of vertices of the convex polygons AA. Then follows nn lines, each line contains two integers xix_i, yiy_i (108xi, yi108-10^8\le x_i,\ y_i\le 10^8), denoting the iith point of the convex polygon AA. The points are given in counter-clockwise order. The next line contains a integer mm (3m300003≤m≤30000), denoting the number of vertices of the convex polygons BB. Then follows mm lines, each line contains two integers xix_i, yiy_i (108xi, yi108-10^8\le x_i,\ y_i\le 10^8), denoting the iith point of the convex polygon BB. The points are given in counter-clockwise order. The last line contains three integers xx,yy and rr,denoting the position of the center of the circle P and the radius of the circle. (108xi, yi108,0r108-10^8\le x_i,\ y_i\le 10^8,0\le r \le 10^8) The data guarantees that the sum of nn will not exceed 21052\cdot 10^5 The data guarantees that the sum of mm will not exceed 21052\cdot 10^5

Output

For each test case print a single floating-point number denoting the probability of AA' intersects with BB.(keep 4 decimal places)

Sample Input

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

Sample Output

0.5247
0.1185

Source

2023“钉耙编程”中国大学生算法设计超级联赛(1)