Minimum spanning tree
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Find the weight of minimum spanning tree for a weighted undirected connected graph.
Input
The first line contains the numbers and , where is the number of vertices in the graph and is the number of edges. Each of the next lines contains a triple of integers , where and are the numbers of vertices connected by an edge and is the weight of edge (a positive number not exceeding ).
Output
Print the weight of minimum spanning tree.
Examples
Input #1
Answer #1
Submissions 5K
Acceptance rate 45%