Problem B
Bumped!

Peter returned from the recently held ACM ICPC World Finals only to find that his return flight was overbooked and he was bumped from the flight! Well, at least he wasn’t beat up by the airline and he’s received a voucher for one free flight between any two destinations he wishes.
He is already planning next year’s trip. He plans to travel by car where necessary, but he may be using his free flight ticket for one leg of the trip. He asked for your help in his planning.
He can provide you a network of cities connected by roads, the amount it costs to buy gas for traveling between pairs of cities, and a list of available flights between some of those cities. Help Peter by finding the minimum amount of money he needs to spend to get from his hometown to next year’s destination!
Input
The input consists of a single test case. The first line
lists five space-separated integers
The first line is followed by
Each of the following
Output
Output the minimum number of cents Peter needs to spend to get from his home town to the competition, using at most one flight. You may assume that there is a route on which Peter can reach his destination.
Sample Input 1 | Sample Output 1 |
---|---|
8 11 1 0 5 0 1 10 0 2 10 1 2 10 2 6 40 6 7 10 5 6 10 3 5 15 3 6 40 3 4 20 1 4 20 1 3 20 4 7 |
45 |
Sample Input 2 | Sample Output 2 |
---|---|
8 11 1 0 5 0 1 10 0 2 10 1 2 10 2 6 40 6 7 10 5 6 10 3 5 15 3 6 40 3 4 20 1 4 20 1 3 30 4 7 |
50 |