# 1708. Connected Gheeves

Gheeves (plural of gheef) are some objects similar to funnels. We define a gheef as a two dimensional object specified by a sequence of points $(p_1, p_2, …, p_n)$ with the following conditions:

1. $3 \le n \le 1000$

2. If a point $p_i$ is specified by the coordinates $(x_i, y_i)$, there is an index $1 \lt c \lt n$ such that $y1 \gt y2 \gt \dots \gt y_c$ and $y_c \lt y_{c+1} \lt y_{c+2} \lt \dots \lt y_n$. $p_c$ is called the cusp of the gheef.

3. For all $1 \le i \lt c$, $x_i \lt x_c$ and for all $c \lt i \le n$, $x_i \gt x_c$.

4. For $1 < i < c$, the amount of rotation required to rotate $p_{i-1}$ around $p_i$ in clockwise direction to become co-linear with $p_i$ and $p_{i+1}$, is greater than 180 degrees. Likewise, for $c < i < n$, the amount of rotation required to rotate $p_{i-1}$ around $p_i$ in clockwise rotation to become co-linear with $p_i$ and $p_{i+1}$, is greater than 180 degrees.

5. The set of segments joining two consecutive points of the sequence intersect only in their endpoints.

For example, the following figure shows a gheef of six points with $c = 4$: We call the sequence of segments $(p_1p_2, p_2p_3, …, p_{n-1}p_n)$, the body of the gheef. In this problem, we are given two gheeves $P = (p_1, p_2, …, p_n)$ and $Q = (q_1, q_2, …, q_m)$, such that all $x$ coordinates of $p_i$ are negative integers and all $x$ coordinates of $q_i$ are positive integers. Assuming the cusps of the two gheeves are connected with a narrow pipe, we pour a certain amount of water inside the gheeves. As we pour water, the gheeves are filled upwards according to known physical laws (the level of water in two gheeves remains the same). Note that in the gheef $P$, if the level of water reaches $min{y_1, y_n}$, the water pours out of the gheef (the same is true for the gheef $Q$). Your program must determine the level of water in the two gheeves after pouring a certain amount of water. Since we have defined our problem in two dimensions, the amount of water is measured in terms of area it fills. Note that the volume of pipe connecting cusps is considered as zero.

### 输入格式

The first number in the input line, t is the number of test cases. Each test case is specified on three lines of input. The first line contains a single integer $a (1 ≤ a ≤ 100000)$ which specifies the amount of water poured into two gheeves. The next two lines specify the two gheeves $P$ and $Q$ respectively, each of the form $k \ x_1 \ y_1 \ x_2 \ y_2 \ \ldots \ x_k \ y_k$ where $k$ is the number of points in the gheef ($n$ for $P$ and $m$ for $Q$), and the $x_i \, y_i$ sequence specify the coordinates of the points in the sequences.

### 输出格式

The output contains t lines, each corresponding to an input test case in that order. The output line contains a single integer L indicating the final level of water, expressed in terms of y coordinates rounded to three digits after decimal points.

### 样例

Input
2
25
3 -30 10 -20 0 -10 10
3 10 10 20 0 30 10
25
3 -30 -10 -20 -20 -10 -10
3 10 10 20 0 30 10

Output
3.536
-15.000


134 人解决，145 人已尝试。

216 份提交通过，共有 512 份提交。

2.4 EMB 奖励。