Intelligence Quotient

No attempts yetTime limit3sMemory limit128 MB

Problem

At the University of Byteland one can study only mathematics and computer science. There are currently nn mathematics students and mm computer science students, and no student studies both majors at the same time.

The rector of the university wants to assemble a team of students to solve all of humankind's hardest problems. He knows every student's intelligence quotient (IQ) and wants the team's total IQ to be as large as possible.

But IQ is not everything: the rector also wants every member of the team to know one another. All mathematics students know each other, and likewise every computer science student knows every other computer science student. Only the acquaintances between students of different majors are given explicitly.

Help the rector assemble a team with the maximum possible total IQ in which all members know one another.

Input

The first line contains three integers nn, mm, and kk (1n,m4001 \le n, m \le 400, 0knm0 \le k \le n \cdot m): the number of mathematics students, the number of computer science students, and the number of acquainted pairs of students from different majors, respectively.

Each of the next kk lines describes one such pair: the ii-th line contains two integers aia_i and bib_i (1ain1 \le a_i \le n, 1bim1 \le b_i \le m), meaning that mathematics student aia_i and computer science student bib_i know each other. Students of each major are numbered from 11.

The next line contains nn integers, the IQs of the mathematics students in order, each in the range [1,109][1, 10^9]. The following line contains mm integers, the IQs of the computer science students, in the same format.

Output

Print a single integer: the maximum possible total IQ of a team in which every pair of members knows each other.