Skip to content
UPEEC

Fewest Hops

Medium#graphs#bfs· solved by 0 · time limit 2.0 s

A network of nn routers is connected by mm cables (undirected). What is the minimum number of cables a packet must cross to go from router ss to router tt? Print -1 if it can't reach.

Input

nn and mm, mm lines u v, then s t.

Output

The minimum number of hops, or -1.

Constraints

1≤n≤1051 \le n \le 10^5, 0≤m≤2×1050 \le m \le 2 \times 10^5

Sample 1

Input

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

Output

2

Sample 2

Input

3 1
1 2
1 3

Output

-1

Sign in or join free to run and submit your solution.