#t511. 城市路
城市路
City Roads
Problem Background
Special for beginners, ^_^
Problem Description
Teacher Luo is invited to a dance in city , while the city he is currently in is city . There are many other cities nearby. Some pairs of cities are not directly connected by a road, while some are, and these roads are bidirectional (there may also be multiple roads between the same pair of cities).
Given the lengths of the directly adjacent city roads, Teacher Luo wants to know the shortest distance from city to city .
Input Format
The input gives , representing cities and roads.
The following lines each contain three integers a b c, meaning there is a road of length between city and city .
Output Format
Output the shortest distance from to . If cannot reach , output .
Sample Input
5 5
1 2 20
2 3 30
3 4 20
4 5 20
1 5 100
Sample Output
90
Constraints
Time limit: 1s; memory limit: 1024 KiB for each test case. , , .