QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB
[0]
Statistics

Bobo has a connected undirected simple graph with n vertices and m edges. The vertices are numbered by 1,2,,n conveniently, and the i-th edge has weight ci.

For each integer k[2,n], Bobo would like to choose a subset of edges to connect the vertices 1,2,,k with each other. The minimum sum of weight of valid subsets is denoted as f(k).

Find the value of f(2),f(3),,f(n).

Input

The input consists of several test cases and is terminated by end-of-file.

The first line of each test case contains two integers n and m.

The i-th of the following m lines contains 3 integers ai, bi and ci which denote the edge between vertices ai and bi with weight ci.

Output

For each test case, print (n1) integers which denote f(2),f(3),,f(n).

Sample Input

4 3
1 4 1
2 4 1
3 4 1
4 6
1 2 1
1 3 2
1 4 3
2 3 4
2 4 5
3 4 6

Sample Output

2
3
3
1
3
6

Constraint

  • 2n26
  • n1mn(n1)2
  • 1ai,bin
  • 1ci1000
  • The number of test cases does not exceed 100.
  • The number of test cases with n>8 does not exceed 5.