'''simple docstring'''




from __future__ import annotations

import math
import random

def      UpperCamelCase_							( _UpperCAmelCase  :				int      ,     _UpperCAmelCase  :				int      ,     _UpperCAmelCase  :				int   )   ->   list[int]:


       """simple docstring"""







       _UpperCAmelCase					:  str											=   d * e - 1
       _UpperCAmelCase					:  Optional[int]											=   0
       _UpperCAmelCase					:  Optional[int]											=   0
       while p == 0:
              _UpperCAmelCase					:  int											=   random.randint(2      ,     n - 1   )
              _UpperCAmelCase					:  Tuple											=   k
              while True:
                     if t % 2 == 0:
                            _UpperCAmelCase					:  Tuple											=   t // 2
                            _UpperCAmelCase					:  Optional[Any]											=   (g**t) % n
                            _UpperCAmelCase					:  int											=   math.gcd(x - 1      ,     _UpperCAmelCase   )
                            if x > 1 and y > 1:
                                   _UpperCAmelCase					:  Union[str, Any]											=   y
                                   _UpperCAmelCase					:  int											=   n // y
                                   break  # find the correct factors
                     else:
                            break  # t is not divisible by 2, break and choose another g
       return sorted([p, q]   )


if __name__ == "__main__":
   import doctest

   doctest.testmod()


'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int      ,     _UpperCAmelCase  :				list[tuple[int, int, int]]   )   ->   list[tuple[int, int, int]]:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[int]											=   sorted(_UpperCAmelCase      ,     key=lambda _UpperCAmelCase   : edge[2]   )

       _UpperCAmelCase					:  Optional[int]											=   list(range(_UpperCAmelCase   )   )

       def find_parent(_UpperCAmelCase  :				Dict   ):
              if i != parent[i]:
                     _UpperCAmelCase					:  Tuple											=   find_parent(parent[i]   )
              return parent[i]

       _UpperCAmelCase					:  Union[str, Any]											=   0
       _UpperCAmelCase					:  Dict											=   []

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

       return minimum_spanning_tree


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

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

  kruskal(num_nodes, edges)

