Given an undirected graph and two vertices and , compute the minimum number of jumps needed to go from to . Here, we say that a jump between two vertices and is possible if there is a vertex adjacent to both and .
Input consists of several graphs. Every case begins with , , and , followed by pairs , with , indicating an edge between and . Suppose , , , that the vertices are numbered between 0 and , and that there are no repeated edges.
For each graph, print the minimum number of jumps to go from
to
.
If it is impossible, print “NO”.
Even if a green light is obtained, only solutions will receive the maximum score.
Input
3 2 1 2 1 0 2 1 4 4 3 2 0 1 1 2 2 0 3 0 2 1 0 1 0 1 5 6 0 1 0 1 1 2 1 3 1 4 2 4 3 4
Output
NO 1 NO 2