Given a connected, weighted, undirected graph of $n$ vertices and $m$ edges. Find weight of its minimum spanning tree.
A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight.
Input:
3 3
1 2 1
2 3 2
3 1 3
Output:
3