def 						UpperCAmelCase							(		lowerCAmelCase_    ,   lowerCAmelCase_							)						->						list[tuple[int, int, int]]:
     a	:     Any						      =    sorted(lowerCAmelCase_    ,   key=lambda lowerCAmelCase_							: edge[2]							)

     a	:     List[str]						      =    list(range(lowerCAmelCase_							)							)

     def find_parent(lowerCAmelCase_							):
          if i != parent[i]:
               a	:     Optional[Any]						      =    find_parent(parent[i]							)
          return parent[i]

     a	:     List[Any]						      =    0
     a	:     Union[str, Any]						      =    []

     for edge in edges:
          a	:     List[Any]						      =    find_parent(edge[0]							)
          a	:     Union[str, Any]						      =    find_parent(edge[1]							)
          if parent_a != parent_b:
               minimum_spanning_tree_cost += edge[2]
               minimum_spanning_tree.append(lowerCAmelCase_							)
               a	:     Tuple						      =    parent_b

     return minimum_spanning_tree


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

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

  kruskal(num_nodes, edges)
import torch
from torch import autograd






class 				_SCREAMING_SNAKE_CASE( autograd.Function						):
   @staticmethod
   def _lowercase(     lowerCAmelCase_				,  lowerCAmelCase_				,  lowerCAmelCase_				,  lowerCAmelCase_     )						->List[str]:
        a	:     str						      =    inputs.numel()
        a	:     str						      =    int(0.0_05 * nb_elems     ) + 1
        if sigmoid:
             a	:     Optional[Any]						      =    (torch.sigmoid(lowerCAmelCase_     ) > threshold).type(inputs.type()     )
        else:
             a	:     Union[str, Any]						      =    (inputs > threshold).type(inputs.type()     )
        if mask.sum() < nb_min:
             # We limit the pruning so that at least 0.5% (half a percent) of the weights are remaining
             a	:     str						      =    inputs.flatten().kthvalue(max(nb_elems - nb_min				,  1     )     ).values
             a	:     Tuple						      =    (inputs > k_threshold).type(inputs.type()     )
        return mask


   @staticmethod
   def _lowercase(     lowerCAmelCase_				,  lowerCAmelCase_     )						->Union[str, Any]:
        return gradOutput, None, None






class 				_SCREAMING_SNAKE_CASE( autograd.Function						):
   @staticmethod
   def _lowercase(     lowerCAmelCase_				,  lowerCAmelCase_				,  lowerCAmelCase_     )						->List[Any]:
        a	:     List[Any]						      =    inputs.clone()
        a      ,				a	:     Optional[Any]						      =    inputs.flatten().sort(descending=lowerCAmelCase_     )
        a	:     Tuple						      =    int(threshold * inputs.numel()     )

        # flat_out and mask access the same memory.
        a	:     Dict						      =    mask.flatten()
        a	:     Optional[Any]						      =    0
        a	:     List[Any]						      =    1
        return mask


   @staticmethod
   def _lowercase(     lowerCAmelCase_				,  lowerCAmelCase_     )						->Tuple:
        return gradOutput, None






class 				_SCREAMING_SNAKE_CASE( snake_case__						):
   @staticmethod
   def _lowercase(     lowerCAmelCase_				,  lowerCAmelCase_     )						->Tuple:
        a	:     Union[str, Any]						      =    inputs.clone()
        a      ,				a	:     List[Any]						      =    inputs.abs().flatten().sort(descending=lowerCAmelCase_     )
        a	:     Optional[int]						      =    int(threshold * inputs.numel()     )

        # flat_out and mask access the same memory.
        a	:     Dict						      =    mask.flatten()
        a	:     Tuple						      =    0
        a	:     List[str]						      =    1
        return mask