Graph and Minimum Spanning Tree

For each edge of a connected weighted undirected graph, print the weight of a minimum spanning tree that is forced to include that edge.

Hard8Minimum spanning treeUnion-findTreeDFSNo attempts yetTime limit2sMemory limit512 MB

Problem

You are given a connected, undirected, weighted graph GG with NN vertices and MM edges. GG has no self-loops, and at most one edge joins any pair of vertices.

For each edge (u,v)(u, v), compute the total weight of a minimum spanning tree that is forced to contain that edge.

Input

The first line contains the number of vertices NN and the number of edges MM (2N2000002 \le N \le 200000, N1M200000N-1 \le M \le 200000).

Each of the next MM lines contains the edge information uu, vv, ww, meaning that the edge joining vertex uu and vertex vv has weight ww (1u,vN1 \le u, v \le N, uvu \ne v, 1w1091 \le w \le 10^9).

Output

For each edge, print the total weight of a minimum spanning tree containing that edge, one per line. Print the answers in the order the edges are given in the input.