Two famous competing companies ChemForces and TopChemist decided to show their sets of recently discovered chemical elements on an exhibition. However they know that no element should be present in the sets of both companies.

In order to avoid this representatives of both companies decided to make an agreement on the sets the companies should present. The sets should be chosen in the way that maximizes the total income of the companies.

All elements are enumerated with integers. The ChemForces company has discovered

$n$

distinct chemical elements with indices

${a}_{1},{a}_{2},\dots ,{a}_{n}$

, and will get an income of

${x}_{i}$

Berland rubles if the

$i$

-th element from this list is in the set of this company.

The TopChemist company discovered

$m$

distinct chemical elements with indices

${b}_{1},{b}_{2},\dots ,{b}_{m}$

, and it will get an income of

${y}_{j}$

Berland rubles for including the

$j$

-th element from this list to its set.

In other words, the first company can present any subset of elements from

$\left\{{a}_{1},{a}_{2},\dots ,{a}_{n}\right\}$

(possibly empty subset), the second company can present any subset of elements from

$\left\{{b}_{1},{b}_{2},\dots ,{b}_{m}\right\}$

(possibly empty subset). There shouldn’t be equal elements in the subsets.

Help the representatives select the sets in such a way that no element is presented in both sets and the total income is the maximum possible.

Input

The first line contains a single integer

$n$

(

$1\le n\le {10}^{5}$

)  — the number of elements discovered by ChemForces.

The

$i$

-th of the next

$n$

lines contains two integers

${a}_{i}$

and

${x}_{i}$

(

$1\le {a}_{i}\le {10}^{9}$

,

$1\le {x}_{i}\le {10}^{9}$

)  — the index of the

$i$

-th element and the income of its usage on the exhibition. It is guaranteed that all

${a}_{i}$

are distinct.

The next line contains a single integer

$m$

(

$1\le m\le {10}^{5}$

)  — the number of chemicals invented by TopChemist.

The

$j$

-th of the next

$m$

lines contains two integers

${b}_{j}$

and

${y}_{j}$

, (

$1\le {b}_{j}\le {10}^{9}$

,

$1\le {y}_{j}\le {10}^{9}$

)  — the index of the

$j$

-th element and the income of its usage on the exhibition. It is guaranteed that all

${b}_{j}$

are distinct.

Output

Print the maximum total income you can obtain by choosing the sets for both companies in such a way that no element is presented in both sets.

Examples
input

Copy

output

Copy

input

Copy

output

Copy

Note

In the first example ChemForces can choose the set (

$3,7$

), while TopChemist can choose (

$1,2,4$

). This way the total income is

$\left(10+2\right)+\left(4+4+4\right)=24$

.

In the second example ChemForces can choose the only element

${10}^{9}$

, while TopChemist can choose (

$14,92,35$

). This way the total income is

$\left(239\right)+\left(15+65+89\right)=408$

.

stl大法好 直接使用map 最后遍历即可