



"""simple docstring"""
import sys
from collections import defaultdict




class 			snake_case_						:






							def __init__(   self      ):
								a_     :      Tuple 						=     []






							def snake_case_  (   self			,     a_      ):
								return self.node_position[vertex]






							def snake_case_  (   self			,     a_			,     a_      ):
								a_     :      List[Any] 						=     pos






							def snake_case_  (   self			,     a_			,     a_			,     a_			,     a_      ):
								if start > size // 2 - 1:
									return
								else:
									if 2 * start + 2 >= size:
										a_     :      str 						=     2 * start + 1
									else:
										if heap[2 * start + 1] < heap[2 * start + 2]:
											a_     :      List[Any] 						=     2 * start + 1
										else:
											a_     :      Optional[int] 						=     2 * start + 2
									if heap[smallest_child] < heap[start]:
										a_     :      Optional[int] 						=     heap[smallest_child], positions[smallest_child]
										a_     :      Optional[int] 						=     (
										    heap[start],
										    positions[start],
										)
										a_     :      Optional[Any] 						=     temp, tempa

										a_     :      int 						=     self.get_position(positions[smallest_child]      )
										self.set_position(
										    positions[smallest_child]			,     self.get_position(positions[start]      )      )
										self.set_position(positions[start]			,     a_      )

										self.top_to_bottom(a_			,     a_			,     a_			,     a_      )






							def snake_case_  (   self			,     a_			,     a_			,     a_			,     a_      ):
								a_     :      Tuple 						=     position[index]

								while index != 0:
									a_     :      Optional[Any] 						=     int((index - 2) / 2      ) if index % 2 == 0 else int((index - 1) / 2      )

									if val < heap[parent]:
										a_     :      Optional[Any] 						=     heap[parent]
										a_     :      Union[str, Any] 						=     position[parent]
										self.set_position(position[parent]			,     a_      )
									else:
										a_     :      List[Any] 						=     val
										a_     :      Tuple 						=     temp
										self.set_position(a_			,     a_      )
										break
									a_     :      Dict 						=     parent
								else:
									a_     :      Union[str, Any] 						=     val
									a_     :      Union[str, Any] 						=     temp
									self.set_position(a_			,     0      )






							def snake_case_  (   self			,     a_			,     a_      ):
								a_     :      Optional[Any] 						=     len(a_      ) // 2 - 1
								for i in range(a_			,     -1			,     -1      ):
									self.top_to_bottom(a_			,     a_			,     len(a_      )			,     a_      )






							def snake_case_  (   self			,     a_			,     a_      ):
								a_     :      List[Any] 						=     positions[0]
								a_     :      List[str] 						=     sys.maxsize
								self.top_to_bottom(a_			,     0			,     len(a_      )			,     a_      )
								return temp



def        lowerCAmelCase_						(							SCREAMING_SNAKE_CASE__	)			->      List[Any]:
	a_     :      Optional[int] 						=     Heap()

	a_     :      List[str] 						=     [0] * len(SCREAMING_SNAKE_CASE__	)
	a_     :      Any 						=     [-1] * len(SCREAMING_SNAKE_CASE__	)  # Neighboring Tree Vertex of selected vertex
	# Minimum Distance of explored vertex with neighboring vertex of partial tree
	# formed in graph
	a_     :      Any 						=     []  # Heap of Distance of vertices from their neighboring vertex
	a_     :      str 						=     []

	for vertex in range(len(SCREAMING_SNAKE_CASE__	)	):
		distance_tv.append(sys.maxsize	)
		positions.append(SCREAMING_SNAKE_CASE__	)
		heap.node_position.append(SCREAMING_SNAKE_CASE__	)

	a_     :      Union[str, Any] 						=     []
	a_     :      List[str] 						=     1
	a_     :      int 						=     sys.maxsize
	for neighbor, distance in adjacency_list[0]:
		a_     :      Union[str, Any] 						=     0
		a_     :      List[str] 						=     distance
	heap.heapify(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	)

	for _ in range(1, len(SCREAMING_SNAKE_CASE__	)	):
		a_     :      Union[str, Any] 						=     heap.delete_minimum(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	)
		if visited[vertex] == 0:
			tree_edges.append((nbr_tv[vertex], vertex)	)
			a_     :      Union[str, Any] 						=     1
			for neighbor, distance in adjacency_list[vertex]:
				if (
				    visited[neighbor] == 0
				    and distance < distance_tv[heap.get_position(SCREAMING_SNAKE_CASE__	)]
				):
					a_     :      Dict 						=     distance
					heap.bottom_to_top(
					    SCREAMING_SNAKE_CASE__, heap.get_position(SCREAMING_SNAKE_CASE__	), SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	)
					a_     :      List[Any] 						=     vertex
	return tree_edges


if __name__ == "__main__":  # pragma: no cover
					# < --------- Prims Algorithm --------- >
					SCREAMING_SNAKE_CASE_				= int(input("""Enter number of edges: """).strip())
					SCREAMING_SNAKE_CASE_				= defaultdict(list)
					for _ in range(edges_number):
										SCREAMING_SNAKE_CASE_				= [int(x) for x in input().strip().split()]
										adjacency_list[edge[0]].append([edge[1], edge[2]])
										adjacency_list[edge[1]].append([edge[0], edge[2]])
					print(prisms_algorithm(adjacency_list))




"""simple docstring"""
def        lowerCAmelCase_						(							SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	)			->      float:
		_validate_point(SCREAMING_SNAKE_CASE__	)
		_validate_point(SCREAMING_SNAKE_CASE__	)
		if len(SCREAMING_SNAKE_CASE__	) != len(SCREAMING_SNAKE_CASE__	):
				raise ValueError("Both points must be in the same n-dimensional space"	)

		return float(sum(abs(a - b	) for a, b in zip(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	)	)	)



def        lowerCAmelCase_						(							SCREAMING_SNAKE_CASE__	)			->      None:
		if point:
				if isinstance(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	):
						for item in point:
								if not isinstance(SCREAMING_SNAKE_CASE__, (int, float)	):
										a_     :      int 						=     (
										    "Expected a list of numbers as input, found "
										    F"""{type(SCREAMING_SNAKE_CASE__	).__name__}"""
										)
										raise TypeError(SCREAMING_SNAKE_CASE__	)
				else:
						a_     :      Dict 						=     F"""Expected a list of numbers as input, found {type(SCREAMING_SNAKE_CASE__	).__name__}"""
						raise TypeError(SCREAMING_SNAKE_CASE__	)
		else:
				raise ValueError("Missing an input"	)



def        lowerCAmelCase_						(							SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	)			->      float:
		_validate_point(SCREAMING_SNAKE_CASE__	)
		_validate_point(SCREAMING_SNAKE_CASE__	)
		if len(SCREAMING_SNAKE_CASE__	) != len(SCREAMING_SNAKE_CASE__	):
				raise ValueError("Both points must be in the same n-dimensional space"	)

		return float(sum(abs(x - y	) for x, y in zip(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__	)	)	)


if __name__ == "__main__":
					import doctest

					doctest.testmod()