The Zerg, having held off the Protoss timing attack, is preparing to counterattack! However, they don't wish to be all that obvious, so they will not take the shortest path to the Protoss natural to counterattack. Instead, they will take the second-shortest path! It is guaranteed there are at least two paths with distinct lengths.
To be clear about what this means, we model the map the Zerg is on as an undirected weighted graph. Let be the length of the shortest path from vertex to vertex . The Zerg is looking for the smallest realizable path length . The Zerg army must start at vertex and end up at vertex , only traveling along edges in the graph. The Zerg army must traverse an edge in its entirety, but is allowed to visit vertices more than once or reuse edges.
The first line will contain two integers, and .
Each of the next lines contains three space-separated integers, , and , indicating there is an undirected edge between vertices and with length .
Output the length of the second-shortest path.
4 4 1 2 100 2 4 200 2 3 250 3 4 100