#t511. 城市路

城市路

City Roads

Problem Background

Special for beginners, ^_^

Problem Description

Teacher Luo is invited to a dance in city nn, while the city he is currently in is city 11. There are many other cities 2∼n−12 \sim n-1 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 11 to city nn.

Input Format

The input gives n,mn, m, representing nn cities and mm roads.

The following mm lines each contain three integers a b c, meaning there is a road of length cc between city aa and city bb.

Output Format

Output the shortest distance from 11 to nn. If 11 cannot reach nn, output −1-1.

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. 1≤n≤20001 \le n \le 2000, 1≤m≤100001 \le m \le 10000, 0≤c≤100000 \le c \le 10000.