The input will contain several possible cases, each including a route map, identification of the start and destination villages, and the maximum distance Jill is willing to travel.
Each case appears in the input as a set of integers separated by blanks and/or ends of lines. The order and interpretation of these integers in each case is as follows:
- NV – the number of villages in the route map. This number will be no larger than 20.
- NR – the number of roads that appear in the route map. Each road connects a distinct pair of villages.
- NR triples, one for each road, containing C1, C2, and DIST – C1 and C2 identify two villages connected by a road, and DIST gives the distance between these villages on that road.
- SV, DV – the numbers associated with the start and destination villages; the villages are numbered 1 to NV.
- MAXDIST – the maximum distance Jill is willing to travel (one way).
The data for the last case will be followed by a single integer with the value –1.