시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 512 MB 1 1 1 100.000%

문제

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 T (1 ≤ T ≤ 10) that represents the number of test cases. Each test case starts with a line with two integers N (1 ≤ N ≤ 20) and M (1 ≤ M ≤ N*(N-1)), that represents the number of check points and the number of paths to consider respectively. In the following M lines, there are 3 integers a, b (0 ≤ a, b < N) and d (1 ≤ d ≤ 500) 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

예제 출력 1

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