Modern Announce Network

Three grade groups each broadcast internally for free; pick a start student so the friend-link forest spanning all three groups uses the fewest edges.

Hard8GraphMinimum spanning treeGreedyUnion-findNo attempts yetTime limit5sMemory limit512 MB

Problem

Teenagers today keep in touch on social networks.

In one high school, NN students use a social network called ICPC (International Community for Programming Contest). Some pairs among those NN students are friends on the network and can send messages to each other. Of the NN students, AA first grade students, BB second grade students and CC third grade students belong to the Programming Society. Some students belong to no society, so A+B+CA+B+C can be smaller than NN.

Members of the same grade get along, so each grade has one group chat. The moment one member of a grade receives a message, every member of that grade receives it as well. Different grades do not get along, and there is no group chat for the whole society or for the whole school.

The administrator of the society has no account on the network. To announce a message, the administrator tells it in person to one of the NN students, and that student spreads it on the network over the group chats and the friend links. Once at least one member of every grade has the message, the announcement counts as delivered to the whole society.

Contacting a friend is a bother, so the society wants as few of those contacts as possible. One contact between friends is one message passed between two students who are friends. Messages that spread inside a grade group chat do not count. Find the smallest number of contacts between friends needed to announce a message to every society member, and the id of the student the administrator should tell first to reach that number.

Input

The input holds a single test case in this format.

N A B C
a1 ... aA
b1 ... bB
c1 ... cC
M
x1 y1
...
xM yM

The first line has four integers NN, AA, BB and CC. NN is the number of students on the network, with 3N100003 \le N \le 10000. AA, BB and CC are the numbers of first, second and third grade society members, with 1A,B,C1 \le A, B, C and A+B+CNA+B+C \le N. Each student is identified by an id between 1 and NN, and no two students share an id.

The second line has the AA ids a1a_1 to aAa_A of the first grade members. The third line has the BB ids b1b_1 to bBb_B of the second grade members. The fourth line has the CC ids c1c_1 to cCc_C of the third grade members. All of these ids are different.

The fifth line has one integer MM, the number of friend pairs, with 2M5000002 \le M \le 500000. Line ii of the next MM lines has two integers xix_i and yiy_i, which mean that the students with ids xix_i and yiy_i are friends, with 1xi,yiN1 \le x_i, y_i \le N and xiyix_i \ne y_i. The same pair never appears twice, in either order.

Using friend links and grade group chats, a message can travel from any student to any other student.

Output

Print the smallest number of contacts between friends needed to announce a message to every society member, then the id of the student the administrator tells the message to first, separated by one space. Messages inside a grade group chat do not count as contacts. When several students reach the smallest number, print the smallest such id.