#icpc2015autumnf. [icpc2015autumn_f]Modern Announce Network

[icpc2015autumn_f]Modern Announce Network

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

Today, modern teenagers use SNS to communicate with each other.

In a high school, NN students are using an SNS called ICPC (International Community for Programming Contest). Some pairs of these NN students are "friends" on this SNS, and can send messages to each other. Among these NN students, AA first grade students, BB second grade students, and CC third grade students are members of the Programming Society. Note that there may be some students who are not the members of the Programming Society, so A+B+CA+B+C can be less than NN.

There are good relationships between members of the same grade in the Society. Thus, there is a chat group in the SNS for each grade, and the Society members of the same grade can communicate with each other instantly via their group chat. On the other hand, the relationships between any different grades are not so good, and there are no chat group for the entire Society and the entire high school.

In order to broadcast a message to all the Society members on the SNS, the administrator of the Society came up with a method: the administrator tells the message to one of the NN students and have them spread the message on the SNS via the chat groups and their friends. (The administrator itself does not have an account for the SNS.) As the members of the same grade can broadcast the message by the chat group for the grade, we can assume that if one of a grade gets the message, all other members of that grade also get the message instantly. Therefore, if the message is told to at least one member of each grade, we can assume that the message is broadcasted to the all members of the Society on the SNS.

Because it is bothering to communicate between friends, we want to minimize the number of communications between friends. What is the minimum number of communications between friends to broadcast a message to all the Society members? Who is the first person to whom the administrator should tell the message to achieve the minimum communications?


Input

The input consists of a single test case. The test case is formatted as follows:

NN AA BB CC
a_1a\_1 ... a_Aa\_A
b_1b\_1 ... b_Bb\_B
c_1c\_1 ... c_Cc\_C
MM
x_1x\_1 y_1y\_1
...
x_Mx\_M y_My\_M

The first line contains four integers NN, AA, BB, and CC. NN (3leqNleq10,0003 \\leq N \\leq 10{,}000) denotes the number of students in the SNS, and AA, BB and CC (1leqA,B,CleqN1 \\leq A, B, C \\leq N and A+B+CleqNA + B + C \\leq N) denote the number of members of the first, second, and third grade respectively. Each student on the SNS is represented by a unique numeric ID between 11 and NN. The second line contains AA integers a_1,cdots,a_Aa\_1, \\cdots, a\_A (1leqa_1,cdots,a_AleqN1 \\leq a\_1, \\cdots, a\_A \\leq N), which are the IDs of members of the first grade. The third line contains BB integers b_1,cdots,b_Bb\_1, \\cdots, b\_B (1leqb_1,cdots,b_BleqN1 \\leq b\_1, \\cdots, b\_B \\leq N), which are the IDs of members of the second grade. The fourth line contains CC integers c_1,cdots,c_Cc\_1, \\cdots, c\_C (1leqc_1,cdots,c_CleqN1 \\leq c\_1, \\cdots, c\_C \\leq N), which are the IDs of members of the third grade. You can assume that $a\_1, \\cdots, a\_A, b\_1, \\cdots, b\_B, c\_1, \\cdots, c\_C$ are distinct. The fifth line contains an integer MM (2leqMleq500,0002 \\leq M \\leq 500{,}000). MM denotes the number of pairs of students who are friends in the SNS. The ii-th line of the following MM lines contains two integers x_ix\_i and y_iy\_i (1leqx_i,y_ileqN1 \\leq x\_i, y\_i \\leq N), which means the student with ID x_ix\_i and the student with ID y_iy\_i are friends in the SNS. You can assume that x_ineqy_ix\_i \\neq y\_i (1leqileqM1 \\leq i \\leq M), and (x_ineqx_jx\_i \\neq x\_j or y_ineqy_jy\_i \\neq y\_j) and (x_ineqy_jx\_i \\neq y\_j or y_ineqx_jy\_i \\neq x\_j) if ineqji \\neq j (1leqi,jleqM1 \\leq i, j \\leq M). You can also assume that a message can be delivered from any student to any student in the SNS via the friends and group chat.

Output

Output the minimum number of communications between friends (not including group chat) to broadcast a message among all the Society members, and the ID of the student to whom the administrator should tell the message in order to achieve the minimum number of communications, separated by a single space. If there are multiple students that satisfy the above constraints, output the minimum ID of such students.



Sample Input 1

4 2 1 1
1 2
3
4
3
1 2
2 4
3 4```

### Output for the Sample Input 1

```plain
2 1```

* * *

### Sample Input 2

```plain
4 1 1 1
2
3
4
4
1 2
1 3
1 4
2 4```

### Output for the Sample Input 2

```plain
3 1```

* * *

### Sample Input 3

```plain
8 1 2 2
5
4 6
3 8
7
1 2
2 3
3 4
5 6
6 7
7 8
2 6```

### Output for the Sample Input 3

```plain
2 3```

* * *