Task
There are cities and bidirectional railways connecting cities and with a travel time of minutes. There is also a train that connects city with city , this train will always take the only shortest path between the two cities.
However, the train only passes through some cities and the mayors of the cities it doesn't pass through are angry.
To please the mayors, you can upgrade a single railway to high-speed railway, which will reduce the travel time by minute for each euro spent. Of course, the travel time must be strictly positive after the upgrade.
You want to upgrade a railway so that the new shortest path between city and city always passes to at least a city that wasn't passed by the train before.
In the new railway network there may be many shortest paths, however the original one must not be one of them.
What is the minimum amount of money you need to spend to achieve this?
Input
The first line contains the integers () and (), the number of cities and the number of railways.
The following lines contains three integers , and representing a bidirectional railway between and with a travel time of minutes. (), ().
It is guaranteed that the shortest path between 0 and is unique.
For tests worth points, (, ).
For tests worth more points, , and each city has exactly two railways.
Example 1
stdin
4 5
0 1 20
0 2 60
1 2 5
2 3 20
1 3 20
stdout
6
Example 2
stdin
4 5
0 1 5
0 2 10
1 2 10
2 3 10
1 3 5
stdout
-1
Output
You need to write a single line with an integer: the minimum amount of money you need to spend so that the new shortest path between city and city always passes through a new city. If it is not possible to achieve this, you need to write .
Notes
In the first sample case, it is possible to upgrade the railway between cities and so that the new shortest path passes through city .
In the second sample case, it is not possible to upgrade a railway so that the new shortest path passes through a new city.