AdvancedRating 1800
Fewest Buses
Each bus route is a loop through some stops. Starting at stop s, print the fewest buses you must ride to reach stop t (0 if s = t), or -1.
Input
r; then r lines (each starts with how many stops, then the stops); then s and t.
Output
One integer.
Sample 1
Input
2 3 1 2 7 3 3 6 7 1 6
Output
2
Sample 2
Input
5 2 7 12 3 4 5 15 1 6 2 15 19 2 9 12 15 12
Output
-1
Output appears here