A university campus has
Given a starting building and a destination building, find the minimum number of paths that must be walked to get from the start to the destination. If the destination cannot be reached at all, report
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of buildings and the number of paths.
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 — a two-way path directly connecting building KaTeX can only parse string typed expression and building KaTeX can only parse string typed expression.
The last line contains two integers, the starting building and the destination building.
Print a single integer — the minimum number of paths needed to reach the destination from the start, or KaTeX can only parse string typed expression if it cannot be reached.
Input
6 6
0 1
1 2
2 3
0 4
4 3
3 5
0 5Output3ExplanationOne shortest route is building 0 to building 4 to building 3 to building 5, using 3 paths. No shorter route exists.
Example 2:
Input
5 0
0 4Output-1ExplanationWith no paths connecting any buildings at all, building 4 cannot be reached from building 0.
Example 3:
Input
3 1
0 1
1 1Output0ExplanationThe starting building and the destination building are the same, so no paths need to be walked at all.