A night bus network connects stops with direct two-way routes. Each route takes exactly one ride. A student starts at stop
Find the minimum number of rides needed, or print
The twist: the route with fewer intermediate stops is not always obvious from the input order.
The first line contains four integers KaTeX can only parse string typed expression, KaTeX can only parse string typed expression, KaTeX can only parse string typed expression, and KaTeX can only parse string typed expression — the number of stops, routes, start stop, and destination stop.
Each of the next KaTeX can only parse string typed expression lines contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression, meaning there is a two-way bus route between stops KaTeX can only parse string typed expression and KaTeX can only parse string typed expression.
Print a single integer — the minimum number of rides from KaTeX can only parse string typed expression to KaTeX can only parse string typed expression, or KaTeX can only parse string typed expression if unreachable.
Input
6 6 1 6
1 2
2 3
3 6
1 4
4 5
5 6Output3ExplanationOne shortest route is KaTeX can only parse string typed expression.
Example 2:
Input
5 3 1 5
1 2
2 3
4 5Output-1ExplanationStop KaTeX can only parse string typed expression is not reachable from stop KaTeX can only parse string typed expression.