#T25. 最短路

最短路

Description

Given a weighted undirected graph with MM edges and NN vertices, find the shortest path from vertex 11 to vertex NN.

Input Format

The first line contains two integers: NN and MM (N100000N \leq 100000, M500000M \leq 500000).
The next MM lines each contain three positive integers: aia_i, bib_i, and cic_i, indicating that there is a path of length cic_i between vertices aia_i and bib_i, where ci1000c_i \leq 1000.

Output Format

An integer representing the shortest distance from vertex 11 to vertex NN.

4 4
1 2 1
2 3 1
3 4 1
2 4 1

2

Hint

【Sample Explanation】 Note that the graph may contain multiple edges and self-loops. The data guarantees there is a path connecting node 11 to node NN.