EXPLORACE
题号:NC54555
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

CodingSchool is conducting an explorace to welcome new students. It is compulsory for each team to visit all check points (not necessarily following the sequence). At each check point, the team will have to complete a specific activity. Each team can plan a strategy on the sequence of check points to visit. The distance of each path is no more than 500 meters.
Because they don’t want the new student to wander away and get lost, CodingSchool wants to put their committee on the paths and only allow the student to use path that have a committee. But CodingSchool only have a limited number of committee, so they don’t want to use all path. Shorter path is preferred because it use less committee. While at the same time, they must make sure that there exists a way to travel between every two checkpoints. Help CodingSchool by determining the minimum total distance of path that they must cover.

输入描述:

First line of input is integer  that represents the number of test cases. Each test case starts with a line with two integers  and  , that represents the number of check points and the number of paths to consider respectively. In the following M lines, there are 3 integers  and  that represent the start check points (a), the end check points (b) and the distance of the path (d) that connects check points a and b.

输出描述:

For each test case, output the minimum distance as shown in the sample output.
示例1

输入

复制
3
5 7
1 2 75
2 3 32
3 4 62
1 4 50
3 5 100
4 5 45
1 5 78
6 8
1 2 70
1 4 82
2 3 57
2 5 105
3 4 160
3 6 55
4 5 97
4 6 75
4 5
1 2 10
1 3 30
1 4 40
2 3 20
3 4 50

输出

复制
Case #1: 189 meters
Case #2: 354 meters
Case #3: 70 meters