from __future__ import annotations

from enum import Enum, unique
from typing import TypeVar

# Create a generic variable that can be 'Enum', or any subclass.
__snake_case			      =    TypeVar('''T''', bound='''Enum''')







@unique
class 			__snake_case   (     lowerCamelCase__   ):
 __lowerCamelCase    :   Tuple     =      80
 __lowerCamelCase    :   Optional[int]     =      70
 __lowerCamelCase    :   str     =      60
 __lowerCamelCase    :   Any     =      50
 __lowerCamelCase    :   Optional[int]     =      40
 __lowerCamelCase    :   Optional[int]     =      30
 __lowerCamelCase    :   Any     =      20
 __lowerCamelCase    :   List[str]     =      10







@unique
class 			__snake_case   (     lowerCamelCase__   ):
 __lowerCamelCase    :   List[str]     =      24
 __lowerCamelCase    :   List[str]     =      21
 __lowerCamelCase    :   Optional[Any]     =      18
 __lowerCamelCase    :   Tuple     =      15
 __lowerCamelCase    :   str     =      12
 __lowerCamelCase    :   Dict     =      9
 __lowerCamelCase    :   str     =      6
 __lowerCamelCase    :   List[str]     =      3
 __lowerCamelCase    :   Union[str, Any]     =      2
 __lowerCamelCase    :   Optional[int]     =      1
 __lowerCamelCase    :   str     =      -1
 __lowerCamelCase    :   Tuple     =      -2
 __lowerCamelCase    :   str     =      -3
 __lowerCamelCase    :   List[Any]     =      -6
 __lowerCamelCase    :   Optional[Any]     =      -9
 __lowerCamelCase    :   List[Any]     =      -12
 __lowerCamelCase    :   Optional[Any]     =      -15
 __lowerCamelCase    :   Dict     =      -18
 __lowerCamelCase    :   Tuple     =      -21
 __lowerCamelCase    :   List[Any]     =      -24
 @classmethod
 def 	UpperCAmelCase__       (  cls						)	->							dict:
       '''simple docstring'''





       return {unit.name: unit.value for unit in cls if unit.value > 0}






 @classmethod
 def 	UpperCAmelCase__       (  cls						)	->							dict:
       '''simple docstring'''





       return {unit.name: unit.value for unit in cls if unit.value < 0}





def   lowerCAmelCase_ (				__lowerCAmelCase						)->  str:






      '''simple docstring'''





      UpperCAmelCase    : Optional[int]      =SIUnit.get_positive() if value > 0 else SIUnit.get_negative()
      for name_prefix, value_prefix in prefixes.items():
            UpperCAmelCase    : int      =value / (10**value_prefix)
            if numerical_part > 1:
                  return f'''{numerical_part!s} {name_prefix}'''
      return str(__lowerCAmelCase						)





def   lowerCAmelCase_ (				__lowerCAmelCase						)->  str:






      '''simple docstring'''





      for prefix in BinaryUnit:
            UpperCAmelCase    : List[Any]      =value / (2**prefix.value)
            if numerical_part > 1:
                  return f'''{numerical_part!s} {prefix.name}'''
      return str(__lowerCAmelCase						)


if __name__ == "__main__":
     import doctest

     doctest.testmod()

def   lowerCAmelCase_ (				__lowerCAmelCase		,					__lowerCAmelCase						)->  list[tuple[int, int, int]]:






      '''simple docstring'''





      UpperCAmelCase    : List[Any]      =sorted(__lowerCAmelCase		,					key=lambda __lowerCAmelCase						: edge[2]						)

      UpperCAmelCase    : Union[str, Any]      =list(range(__lowerCAmelCase						)						)

      def find_parent(__lowerCAmelCase						):
            if i != parent[i]:
                  UpperCAmelCase    : Optional[int]      =find_parent(parent[i]						)
            return parent[i]

      UpperCAmelCase    : Optional[Any]      =0
      UpperCAmelCase    : List[str]      =[]

      for edge in edges:
            UpperCAmelCase    : Dict      =find_parent(edge[0]						)
            UpperCAmelCase    : Optional[Any]      =find_parent(edge[1]						)
            if parent_a != parent_b:
                  minimum_spanning_tree_cost += edge[2]
                  minimum_spanning_tree.append(__lowerCAmelCase						)
                  UpperCAmelCase    : Optional[Any]      =parent_b

      return minimum_spanning_tree


if __name__ == "__main__":  # pragma: no cover
     __snake_case      ,  __snake_case			      =    list(map(int, input().strip().split()))
     __snake_case			      =    []

     for _ in range(num_edges):
          __snake_case      ,  __snake_case      ,  __snake_case			      =    (int(x) for x in input().strip().split())
          edges.append((nodea, nodea, cost))

     kruskal(num_nodes, edges)
