St Andrews Online Judge

Medical Students on Instagram

By Kay Akashi

Time: 3000 ms
Memory: 256000 kB

The code judging system is only available during contests. Check out the github repo for test cases and solutions.

Please log in.

Problem Statement

There're NN students on Instagram in the University. Students are numbered from 11 to NN. Kay is curious about how close medical students are with other people in the University on Instagram, so he's going to conduct a brief research, looking at CC students from medical school.

Medical students are numbered P1,...,PCP_{1}, ..., P_{C}. According to the statistics, there're MM mutual connections in total, and student xix_{i} and yiy_{i} (1iM,1xi,yiN1 \leq i \leq M, 1 \leq x_{i}, y_{i} \leq N) are following each other. Considering these connections as a network, Kay defined "distance" between two users as the minimal number of connections from one to reach the other. Distance between one user and him/herself is defined 00.

Kay wants to know, for each student ii in the University, the minimum possible distance between student ii and mm (mPm ∈ P) in the University. If student ii is a medical student, output 00. If there's neither direct nor indirect connection between student ii and any medical student, output 1-1.

Constraints

2N4×1052 \leq N \leq 4 × 10^{5}. 1M1051 \leq M \leq 10^{5}.

1CN1 \leq C \leq N.

Subtask 1 (20%)

2N1002 \leq N \leq 100

Subtask 2 (80%)

2N4×1052 \leq N \leq 4 × 10^{5}.

Input

The first line of input contains three integers, NN, MM, and CC. The second line contains CC numbers, P1,...,PCP_{1}, ..., P_{C}. Then, MM lines follow, each of which consists of two integers, xix_{i} and yiy_{i}. It is guaranteed that one pair of connection appears in the input no more than twice.

Output

Output the answers in a single line, separated by a single space.

Examples

Input

10 8 3
1 9 4
1 2
1 7
3 9
3 4
3 6
4 5
4 6
6 8

Output

0 1 1 0 1 1 1 2 0 -1

Explanation

For example, from the perspective of student 88, distance between him and medical student 11 can be considered infinitely large. Between 88 and medical student 99, the distance is 33. Between student 88 and medical student 44, the distance is 22. Thus, the answer is 22 for student 88.

Input

6 6 3
1 2 3
1 2
2 3
3 1
4 5
5 6
6 4

Output

0 0 0 -1 -1 -1

Explanation

Students 44, 55, and 66 cannot reach any medical student whatsoever. In that case, output 1-1.