

"""simple docstring"""





def 							_lowerCAmelCase   (    UpperCAmelCase  :				int   ,				UpperCAmelCase  :				list[tuple[int, int, int]]					):


					'''simple docstring'''






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

					UpperCamelCase__		:     str								=list(range(UpperCAmelCase					)					)

					def find_parent(UpperCAmelCase  :				Optional[Any]					):
										if i != parent[i]:
															UpperCamelCase__		:     List[str]								=find_parent(parent[i]					)
										return parent[i]

					UpperCamelCase__		:     List[Any]								=0
					UpperCamelCase__		:     List[Any]								=[]

					for edge in edges:
										UpperCamelCase__		:     Union[str, Any]								=find_parent(edge[0]					)
										UpperCamelCase__		:     int								=find_parent(edge[1]					)
										if parent_a != parent_b:
															minimum_spanning_tree_cost += edge[2]
															minimum_spanning_tree.append(UpperCAmelCase					)
															UpperCamelCase__		:     Union[str, Any]								=parent_b

					return minimum_spanning_tree


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

				for _ in range(num_edges):
								_SCREAMING_SNAKE_CASE							,							_SCREAMING_SNAKE_CASE							,							_SCREAMING_SNAKE_CASE							:	List[Any]										=			(int(x) for x in input().strip().split())
								edges.append((nodea, nodea, cost))

				kruskal(num_nodes, edges)





"""simple docstring"""





def 							_lowerCAmelCase   (    UpperCAmelCase  :				int					):


					'''simple docstring'''






					if not isinstance(UpperCAmelCase   ,				UpperCAmelCase					):
										raise ValueError('''double_factorial() only accepts integral values'''					)
					if n < 0:
										raise ValueError('''double_factorial() not defined for negative values'''					)
					return 1 if n <= 1 else n * double_factorial(n - 2					)


if __name__ == "__main__":
				import doctest

				doctest.testmod()


