By Kay Akashi
There're students on Instagram in the University. Students are numbered from to . 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 students from medical school.
Medical students are numbered . According to the statistics, there're mutual connections in total, and student and () 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 .
Kay wants to know, for each student in the University, the minimum possible distance between student and () in the University. If student is a medical student, output . If there's neither direct nor indirect connection between student and any medical student, output .
. .
.
.
The first line of input contains three integers, , , and . The second line contains numbers, . Then, lines follow, each of which consists of two integers, and . It is guaranteed that one pair of connection appears in the input no more than twice.
Output the answers in a single line, separated by a single space.
10 8 3
1 9 4
1 2
1 7
3 9
3 4
3 6
4 5
4 6
6 8
0 1 1 0 1 1 1 2 0 -1
For example, from the perspective of student , distance between him and medical student can be considered infinitely large. Between and medical student , the distance is . Between student and medical student , the distance is . Thus, the answer is for student .
6 6 3
1 2 3
1 2
2 3
3 1
4 5
5 6
6 4
0 0 0 -1 -1 -1
Students , , and cannot reach any medical student whatsoever. In that case, output .