Given a weighted undirected graph. Find the sum of weights of edges of a Minimum Spanning Tree.
Input:
Given 2 integers N and M. N represents the number of vertices in the graph. M represents the number of edges between any 2 vertices.
Then M lines follow, each line has 3 space separated integers ai , bi, wi where ai and bi represents an edge from a vertex ai to a vertex bi and wi respresents the weight of that edge.
Output:
Print the summation of edges weights in the MST.
Constraints:
2≤N≤10000
1≤M≤100000
1≤ai,bi≤N
1≤wi≤1000