
"""simple docstring"""







def        __lowerCAmelCase							(_UpperCamelCase						):
	__lowerCAmelCase     :		Union[str, Any]		     = [True for i in range(n + 1						)]
	__lowerCAmelCase     :		Union[str, Any]		     = [i - 1 for i in range(n + 1						)]
	__lowerCAmelCase     :		str		     = []
	for i in range(2			,    n + 1						):
		if is_prime[i]:
			primes.append(_UpperCamelCase						)
		for j in range(0			,    len(_UpperCamelCase						)						):
			if i * primes[j] >= n:
				break
			__lowerCAmelCase     :		List[str]		     = False

			if i % primes[j] == 0:
				__lowerCAmelCase     :		List[Any]		     = totients[i] * primes[j]
				break

			__lowerCAmelCase     :		Tuple		     = totients[i] * (primes[j] - 1)

	return totients


if __name__ == "__main__":
							import doctest

							doctest.testmod()

"""simple docstring"""







def        __lowerCAmelCase							(_UpperCamelCase			,    _UpperCamelCase						):
	__lowerCAmelCase     :		Any		     = sorted(_UpperCamelCase			,    key=lambda _UpperCamelCase						: edge[2]						)

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

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

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

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

	return minimum_spanning_tree


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

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

							kruskal(num_nodes, edges)