Morning light hits the gristmill of Rye Hollow as Mira unrolls the day's manifest of routes. The tally will decide the next shipment. Task: Print the minimum number of edges on a path from s to t, or -1. Input format: First line: n m s t. Next m lines: u v. Output format: Print the BFS distance or -1. Constraints: 1 <= n <= 524; 0 <= m <= 1048.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= n <= 524; 0 <= m <= 1048.
