Vials

No attempts yetTime limit3sMemory limit256 MB

Problem

Bajtazar is a chemist. He is running an experiment that produces remedy X, a mixture that solves every problem of humankind.

Bajtazar has nn vials numbered 11 through nn, and each vial holds a different liquid substance. Vial ii holds a whole number of grams of substance ii. Producing remedy X takes a sequence of mm steps. One step pours the entire contents of one vial into another vial. Assume the vials are large enough and that no drop is spilled while pouring. The vial that was poured out goes on a shelf and is not used again during the experiment.

Some pairs of substances react with each other and form a compound that settles as sediment. In each such reaction 11 gram of the first substance combines with 11 gram of the second, and 22 grams of sediment appear. The reaction runs until one of its substrates is used up. The sediment reacts with nothing and stays on the wall of the vial where it formed until the experiment ends. Some reactions run faster than others. If several substances end up in one solution at the same time, the reactions between pairs of substances happen in a fixed order that Bajtazar knows. After each step Bajtazar waits until the substances in the destination vial have finished reacting, and only then performs the next step.

Bajtazar wonders whether his sequence of steps is optimal. He wants to know how much of the substrates is wasted once every step is done. Find the total number of grams of sediment.

Input

The first line contains three integers nn, mm, kk (0m<n2000000 \le m < n \le 200000, 0k5000000 \le k \le 500000): the number of vials (which is also the number of distinct substances), the number of steps in the experiment, and the number of substance pairs that react and form sediment.

The second line contains nn integers g1,g2,,gng_1, g_2, \dots, g_n (1gi1091 \le g_i \le 10^9), where gig_i is the initial number of grams of substance ii in vial ii.

Each of the next mm lines describes one step, in order. The ii-th of these lines contains two integers aia_i, bib_i (1ai,bin1 \le a_i, b_i \le n, aibia_i \ne b_i), meaning that step ii pours the contents of vial aia_i into vial bib_i. If a vial is poured out in some step, it does not appear in any later step.

Each of the next kk lines describes one pair of substances that forms sediment. The ii-th of these lines contains two integers cic_i, did_i (1ci,din1 \le c_i, d_i \le n, cidic_i \ne d_i), meaning that if substances cic_i and did_i are in one vial at the same time, they react and sediment forms. The pairs are listed from the highest reaction priority to the lowest. If a vial holds two or more reacting pairs, the pair listed earlier in the input starts reacting first and finishes completely before the next pair starts. Ignoring the order inside a pair, the same pair (ci,di)(c_i, d_i) never appears twice.

Output

Print one integer, the total number of grams of sediment after the whole sequence of steps.