Under construction

Still being built. Things may change

Rick's Robe

Interview

Time limit3sMemory limit1024 MB

Summary
Given a graph with wet vertices and existing holes, find the vertex for a new hole that minimizes the time for every wet point to reach its nearest hole.
Level

Medium5 of 10

Topics
BFS, Graph, Brute force
Solved
No attempts yet

Statement

Rick decided to wash his robe. He has little time before his next crazy adventure, so instead of a proper wash he wet ss points of the robe with a special solution and is now waiting for the robe to dry.

The solution Rick made has a kind of mind of its own. Instead of evaporating, it spreads across the robe. The robe can be represented as an undirected graph with nn vertices and mm edges. The wet points are kk distinct vertices of the graph. The robe is also old and has tt holes (another tt distinct vertices), and the solution can drain through them.

Rick would never make a solution that works inefficiently. The solution from each initial point flows to the nearest hole and drains out through it. Passing through one edge of the fabric takes one unit of time. Any amount of solution can flow along one edge at the same time.

Rick computed how long it takes for all the solution to drain out through the holes and decided that this is too long. So he wants to make one more hole at any vertex to speed up the process. Help him find the vertex to make a hole in, so that the time until every drop reaches its nearest hole is minimized.

The solution acts instantly, so after the solution is applied, you may make a hole at a spot where the solution already is, if that minimizes the answer. If several choices are possible, Rick asks you to find the vertex with the smallest number at which adding a hole minimizes the required distance.

Input

The first line contains four integers nn, mm, ss, and tt separated by spaces: the number of vertices and edges of the robe, the number of initially wet points, and the number of holes. (1⩽n,m⩽2⋅1051 \leqslant n, m \leqslant 2 \cdot 10^5; 1⩽s⩽min⁡(n,100)1 \leqslant s \leqslant \min(n, 100); 1⩽t⩽n1 \leqslant t \leqslant n).

The next line contains kk distinct integers pip_i, the numbers of the vertices that Rick wet with the solution (1⩽pi⩽n1 \leqslant p_i \leqslant n).

The next line contains tt distinct integers qiq_i, the numbers of the vertices where the robe has holes (1⩽qi⩽n1 \leqslant q_i \leqslant n).

Each of the next mm lines contains two integers viv_i and uiu_i, meaning there is an edge between vertices uiu_i and viv_i (1⩽vi,ui⩽n1 \leqslant v_i, u_i \leqslant n).

Output

Print on one line, separated by a space, the number of the vertex to make a hole in and the minimum drying time of the robe.

You may print the number of a vertex that already has a hole if no other choice improves the answer. If several answers are possible, print the one with the smallest vertex number, whether or not that vertex already has a hole.

Examples1

  1. Example 1

    Input
    7 6 4 1
    4 5 6 7
    1
    1 2
    2 3
    3 4
    4 5
    3 6
    6 7
    
    Expected output
    3 2