Minimum spanning tree#981

Minimum spanning tree

1 second
128 megabytes
Easy

Find the weight of the minimum spanning tree for an undirected weighted connected graph.

Input

The first line contains the number of vertices and the number of edges (1 \leq n \leq 100, 1 \leq m \leq 6000). Each of the following lines contains three integers , , , where and are the vertex numbers connected by an edge, and is the weight of the edge (a positive integer not exceeding ).

Output

Print the weight of the minimum spanning tree.

Examples

Example 1

Loading
Loading