Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

EIMINSPAN - Minimum Spanning Tree

Given an undirected graph with n vertices and m edges. Find minimum spanning tree and calculate its total length, if you cannot form the tree, print -1.

Input

- First line contains n and m

- Next m lines, each line contains three integers represent for and edge: vertex1, vertex2 and length

Output

print the minimum spanning tree's total length if found, otherwise print -1

Example

Input:
5 3
5 3 2 1 97 1 3 37 2 0 11 Output: -1
Input:
5 3
5 10 4 1 48 4 2 53 1 3 62 0 1 54 3 2 64 0 4 61 1 2 41 4 3 7 3 0 63 2 0 43 Output: 139

Added by:Ha Minh Ngoc
Date:2024-06-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.