Pineapple


Sindra is stuck in Italy! While this would not commonly be a problem, they are in danger, for Sindra greatly enjoys the consumption of pineapple on pizza.

Italy can be represented as a graph of nn nodes and mm edges. Each edge has a weight w[i]w[i], representing how many angry italians will verbally abuse Sindra if they choose to cross that street.

As Sindra's FIT2004 lecturer, can you help them discover the minimum number of times they could be verbally abused as they traverse the graph from node 00 to node n−1n-1?

Input Format

The first line of input will consist of two integers, nn and mm. The following mm lines will each consist of three integers aa bb cc, representing the starting position, ending position and cost respectively of a single edge.

Output Format

The output should consist of a single integer, the minimum number of verbal abuses.

Constraints

1≤n≤m≤1e51 \le n \le m \le 1e5

0≤a,b≤n−10 \le a,b \le n-1

1≤c≤1e31 \le c \le 1e3

Sample Input

Input 1
3 3
0 2 11
0 1 5
1 2 5

Sample Output

Output 1
10

Sample Explanation

The optimal route is 0−>1−>20->1->2, resulting in 5+5=105+5=10 cost. This is the minimum number.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.