After weeks of training, William finally found out how to win a marathon: by cheating! He teamed up with a skillful driver, his friend Alessandro, and is planning on driving instead of running.
The marathon takes place in the beautiful city of Pordenone, which is formed by intersections and bidirectional roads. Each road is exactly meters long.
The marathon starts at intersection and ends at intersection . Marathoners must go through checkpoints given in the array , however, they can run through any route between two consecutive checkpoints.
William's plan is the following:
He will run from the starting line to the first checkpoints, then he will sneak into Alessandro's car and reach the second checkpoint, next, he will run another piece to the following checkpoint. After that, he will sneak again into Alessandro's car and reach the following checkpoint and so on until he reach the finishing line.
Since William wants to win the marathon, he will always take the shortest path between two checkpoints. However, while trying to hide the evidence of the cheat, William lost the original arrangement of the checkpoints!
In order to plan for the worst case scenario, William is interested in the maximum distance he will have to run among all the possible checkpoint arrangements. Can you help him?
Input data
The first line of the input contains the integers and . The second line contains the integer , followed by integers , even.
Each of the following lines contains integers , and describing a road of length connecting intersections and .
Output data
You will need to write in the output a single integer: the maximum distance that William will have to run among all the possible checkpoint arrangements.
Constraints and clarifications
- , even.
- For tests worth points, = .
- For tests worth more points,
Example 1
stdin
7 8
2 4 3
0 1 5
0 2 3
1 4 1
2 3 4
1 3 13
4 5 6
1 6 10
5 6 2
stdout
27
Explanation
In the first sample case, the maximum distance is obtained from the arrangement :
First, William will run from to , the shortest path is with length ;
Then Alessandro will take William to . Finally William will run from to , the shortest path is with length .
The total distance is .
Example 2
stdin
4 5
0
0 1 4
0 2 2
1 2 0
1 3 6
2 3 9
stdout
8
Explanation
In the second sample case there are no checkpoints, so William must run directly from to . The shortest path is .