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 nodes and edges. Each edge has a weight , 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 to node ?
Input Format
The first line of input will consist of two integers, and . The following lines will each consist of three integers , 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
Sample Input
3 3
0 2 11
0 1 5
1 2 5
Sample Output
10
Sample Explanation
The optimal route is , resulting in cost. This is the minimum number.
Comments