Question
The Campus Navigator's Shortest Route

A university campus has N buildings, numbered 0 to N-1, connected by M walking paths. Each path directly connects two buildings and can be walked in either direction, and every path takes exactly the same amount of time to walk (one unit).

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 -1.

Input

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.

Output

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.

Example
Example 1:
Input
6 6

0 1
1 2
2 3
0 4
4 3
3 5
0 5
Output
3
Explanation
One 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 4
Output
-1
Explanation
With no paths connecting any buildings at all, building 4 cannot be reached from building 0.

Example 3:
Input
3 1

0 1
1 1
Output
0
Explanation
The starting building and the destination building are the same, so no paths need to be walked at all.

Online