Yazid is a student at Tsinghua University who loves snacks.
Yazid has $n$ bags of potato chips, which he has numbered from $1$ to $n$ (since they all have different flavors). Yazid also has $m$ bags of dried fruit, which he has numbered from $1$ to $m$.
To avoid ambiguity, we define two snacks to be of the same type if and only if they are both potato chips or both dried fruit.
Yazid plans to eat all the snacks in a certain order. Once he starts eating a bag of snacks, he will not eat any other snacks until that bag is finished. In other words, Yazid's eating order can be represented as a permutation of the snacks to be eaten.
Eating the same type of food consecutively might provide a unique experience, so each bag of snacks has a wonderful value. The wonderful value of the potato chip numbered $i$ ($1\leq i\leq n$) is $a_i$, and the wonderful value of the dried fruit numbered $i$ ($1\leq i\leq m$) is $b_i$.
We guarantee that the wonderful values of all snacks are integers, but note that they may be negative.
When eating each bag of snacks, if Yazid has previously eaten a snack of the same type, he gains happiness equal to the wonderful value of the current snack (no happiness is gained when eating the first snack). Initially, Yazid's happiness is $0$.
Yazid wants to obtain the maximum possible happiness (note that this value may be negative).
Hungry Yazid also needs to eat his way through the 19 cafeterias at Tsinghua University, so please help him calculate the maximum happiness he can obtain.
Input
This problem contains multiple test cases. The first line contains a non-negative integer $T$, representing the number of test cases. The following lines describe each test case:
The first line contains a positive integer $n$, representing the number of potato chips.
The second line contains $n$ space-separated integers $a_1, \dots, a_n$, representing the wonderful values of all potato chips.
The third line contains a positive integer $m$, representing the number of dried fruit.
The fourth line contains $m$ space-separated integers $b_1, \dots, b_m$, representing the wonderful values of all dried fruit.
Output
For each test case, output a single integer on a new line representing the maximum happiness Yazid can obtain.
Examples
Input 1
4
1
100
1
-2
1
-100
2
20 -10
3
1 -1 1
2
-1 1
5
2 3 3 -3 -3
5
6 6 6 -6 -6
Output 1
0
20
3
26
Note 1
For convenience, we denote $A_i$ as the potato chip numbered $i$ and $B_i$ as the dried fruit numbered $i$.
For the first test case: No matter what order the snacks are eaten in, Yazid will not gain any happiness, so the answer is $0$.
For the second test case: An optimal strategy is $B_2 \rightarrow B_1 \rightarrow A_1$, where he gains $20$ happiness when eating $B_1$. It can be proven that no better solution exists.
For the third test case: By eating in the order $B_1 \rightarrow B_2 \rightarrow A_2 \rightarrow A_3 \rightarrow A_1$, he gains $3$ happiness. It can be proven that no better solution exists.
Subtasks
| Test Case ID | $\sum(n+m)\le $ | $n,m\le $ | $\vert a_i\vert ,\vert b_i\vert \le $ | Other Constraints | Score |
|---|---|---|---|---|---|
| $1$ | $300$ | $4$ | $1,000$ | None | $7$ |
| $2$ | $2\times 10^6$ | $10^5$ | $1$ | None | $8$ |
| $3$ | $2\times 10^6$ | $10^5$ | $2$ | None | $11$ |
| $4$ | $2\times 10^6$ | $10^5$ | $10^9$ | All $a_i, b_i$ are negative | $9$ |
| $5$ | $10^4$ | $10^3$ | $10^9$ | None | $23$ |
| $6$ | $2\times 10^6$ | $10^5$ | $10^9$ | None | $42$ |
Here, $\sum (n+m)$ denotes the sum of $n$ and $m$ for all test cases in that test point. For example, $\sum (n+m)$ in Example 1 is $1+1+1+2+3+2+5+5=20$.
For all test points, it is guaranteed that $T\leq 5,000$ and $\sum (n+m)\leq 2\times 10^6$.
For all data in each test point, it is guaranteed that $n, m \leq 100,000$ and $1 \leq |a_i|, |b_i| \leq 10^9$.
For all test points, it is guaranteed that: the maximum values of $n, m$ and the maximum values of $|a_i|, |b_i|$ across all data will not be less than $2/3$ of the upper bounds for that test point; $\sum (n+m)$ will also not be less than half of the corresponding upper bound. Hack data on QOJ is not subject to this restriction.
After submitting your code, the pretest data will be evaluated and the results returned. This problem's pretest data contains 6 test points, each with the same data scale limits as the corresponding final test point.
Note: The evaluation results of the pretest data have no relation to the final evaluation results.