In a galaxy far, far away, the fastest method of transportation is using hypertubes. Each hypertube
directly connects
Input Specification
The first line of input contains three positive integers:
Each of the following
Output Specification
The first and only line of output must contain the required minimum number of stations. If it isn't
possible to travel from station -1
.
Sample Input 1
9 3 5
1 2 3
1 4 5
3 6 7
5 6 7
6 8 9
Sample Output 1
4
Explanation for Sample Output 1
It is possible to travel from station
Sample Input 2
15 8 4
11 12 8 14 13 6 10 7
1 5 8 12 13 6 2 4
10 15 4 5 9 8 14 12
11 12 14 3 5 6 1 13
Sample Output 2
3
Comments