#D11711. Graph
Graph
Graph
problem
You were solving a flow problem that is typical of graph algorithms. The graph given in the problem is vertices and edges, with edges from vertices to vertices with capacity and cost . However, AOR Ika played a trick on the input case. As a result, the order of was shuffled, making it impossible to distinguish between vertex information and capacity information.
So you gave up trying to find the flow between and decided to find the shortest distance between . You decide to use two of the input cases with shuffled order of as vertex information and edge the cost . In other words, the cost is placed on one of the three candidates from to , to , and to .
Find the minimum value of "the shortest distance from s to t" among the possible graphs.
input
output
Output the minimum value of "the shortest distance from to " in one line among the possible graphs. Also, output a line break at the end.
Example
Input
5 3 1 4 3 1 2 5 3 4 2 3 5 4 2 2
Output
7
inputFormat
input case. As a result, the order of was shuffled, making it impossible to distinguish between vertex information and capacity information.
So you gave up trying to find the flow between and decided to find the shortest distance between . You decide to use two of the input cases with shuffled order of as vertex information and edge the cost . In other words, the cost is placed on one of the three candidates from to , to , and to .
Find the minimum value of "the shortest distance from s to t" among the possible graphs.
input
outputFormat
output
Output the minimum value of "the shortest distance from to " in one line among the possible graphs. Also, output a line break at the end.
Example
Input
5 3 1 4 3 1 2 5 3 4 2 3 5 4 2 2
Output
7
样例
5 3 1 4
3 1 2 5
3 4 2 3
5 4 2 2
7