




from __future__ import annotations

from typing import Any

class 		lowercase_       :




					def __init__(   self:		Union[str, Any],     _lowercase:		Any,     _lowercase:		Any):  # noqa: A002


									'''simple docstring'''


									__lowerCAmelCase					=  item
									__lowerCAmelCase					=  next





class 		lowercase_       :




					def __init__(   self:		str):


									'''simple docstring'''


									__lowerCAmelCase					=  None
									__lowerCAmelCase					=  0




					def     _lowercase						(   self:		Dict,     _lowercase:		Any):


									'''simple docstring'''


									__lowerCAmelCase					=  Node(_lowercase,     self.head)
									self.size += 1




					def     _lowercase						(   self:		Optional[Any]):


									'''simple docstring'''


									if self.head is None:
													return None
									else:
													__lowerCAmelCase					=  self.head.item
													__lowerCAmelCase					=  self.head.next
													self.size -= 1
													return item




					def     _lowercase						(   self:		str):


									'''simple docstring'''


									return self.head is None




					def __str__(   self:		Dict):


									'''simple docstring'''


									if self.is_empty():
													return ""
									else:
													__lowerCAmelCase					=  self.head
													__lowerCAmelCase					=  """"""
													__lowerCAmelCase					=  []
													while iterate:
																	item_list.append(str(iterate.item))
																	__lowerCAmelCase					=  iterate.next

													__lowerCAmelCase					=  """ --> """.join(_lowercase)

													return item_str







					def __len__(   self:		str):


									'''simple docstring'''


									return self.size









def 			__SCREAMING_SNAKE_CASE		(		UpperCamelCase		:      int     ,					UpperCamelCase		:      list[tuple[int, int, int]]	)     ->	list[tuple[int, int, int]]:



	"""simple docstring"""






	a_     			=   sorted(UpperCamelCase     ,					key=lambda UpperCamelCase	: edge[2]	)

	a_     			=   list(range(UpperCamelCase	)	)

	def find_parent(UpperCamelCase		:      Any	):
		if i != parent[i]:
			a_     			=   find_parent(parent[i]	)
		return parent[i]

	a_     			=   0
	a_     			=   []

	for edge in edges:
		a_     			=   find_parent(edge[0]	)
		a_     			=   find_parent(edge[1]	)
		if parent_a != parent_b:
			minimum_spanning_tree_cost += edge[2]
			minimum_spanning_tree.append(UpperCamelCase	)
			a_     			=   parent_b

	return minimum_spanning_tree


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

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

			kruskal(num_nodes, edges)