



"""simple docstring"""







import sys
from collections import defaultdict
class 			__A			:







		'''simple docstring'''





		def __init__(      self		:    List[Any]		)   ->						List[Any]:






				"""simple docstring"""



				lowercase__  :       List[Any]												=     []







		def    UpperCAmelCase       (      self		:    Optional[Any]     ,_snake_case		:    Any		)   ->						Optional[int]:






				"""simple docstring"""



				return self.node_position[vertex]







		def    UpperCAmelCase       (      self		:    Optional[int]     ,_snake_case		:    Dict     ,_snake_case		:    int		)   ->						str:






				"""simple docstring"""



				lowercase__  :       List[Any]												=     pos







		def    UpperCAmelCase       (      self		:    Dict     ,_snake_case		:    Optional[Any]     ,_snake_case		:    Dict     ,_snake_case		:    Union[str, Any]     ,_snake_case		:    Optional[int]		)   ->						List[str]:






				"""simple docstring"""



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

								lowercase__  :       Union[str, Any]												=     self.get_position(positions[smallest_child]		)
								self.set_position(
								    positions[smallest_child]     ,self.get_position(positions[start]		)		)
								self.set_position(positions[start]     ,snake_case__		)

								self.top_to_bottom(snake_case__     ,snake_case__     ,snake_case__     ,snake_case__		)







		def    UpperCAmelCase       (      self		:    Optional[Any]     ,_snake_case		:    int     ,_snake_case		:    Union[str, Any]     ,_snake_case		:    Optional[int]     ,_snake_case		:    Union[str, Any]		)   ->						Tuple:






				"""simple docstring"""



				lowercase__  :       Optional[Any]												=     position[index]

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

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







		def    UpperCAmelCase       (      self		:    List[str]     ,_snake_case		:    Any     ,_snake_case		:    Any		)   ->						Any:






				"""simple docstring"""



				lowercase__  :       Union[str, Any]												=     len(snake_case__		) // 2 - 1
				for i in range(snake_case__     ,-1     ,-1		):
						self.top_to_bottom(snake_case__     ,snake_case__     ,len(snake_case__		)     ,snake_case__		)







		def    UpperCAmelCase       (      self		:    List[Any]     ,_snake_case		:    Any     ,_snake_case		:    Tuple		)   ->						Tuple:






				"""simple docstring"""



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





def 	__UpperCAmelCase (       __lowerCamelCase      )				-> Tuple:
		lowercase__  :       str												=     Heap()

		lowercase__  :       Dict												=     [0] * len(__lowerCamelCase      )
		lowercase__  :       Optional[Any]												=     [-1] * len(__lowerCamelCase      )  # Neighboring Tree Vertex of selected vertex
		# Minimum Distance of explored vertex with neighboring vertex of partial tree
		# formed in graph
		lowercase__  :       int												=     []  # Heap of Distance of vertices from their neighboring vertex
		lowercase__  :       Union[str, Any]												=     []

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

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

		for _ in range(1		,	len(__lowerCamelCase      )      ):
				lowercase__  :       Optional[Any]												=     heap.delete_minimum(__lowerCamelCase		,	__lowerCamelCase      )
				if visited[vertex] == 0:
						tree_edges.append((nbr_tv[vertex], vertex)      )
						lowercase__  :       int												=     1
						for neighbor, distance in adjacency_list[vertex]:
								if (
								    visited[neighbor] == 0
								    and distance < distance_tv[heap.get_position(__lowerCamelCase      )]
								):
										lowercase__  :       Tuple												=     distance
										heap.bottom_to_top(
										    __lowerCamelCase		,	heap.get_position(__lowerCamelCase      )		,	__lowerCamelCase		,	__lowerCamelCase      )
										lowercase__  :       Optional[Any]												=     vertex
		return tree_edges


if __name__ == "__main__":  # pragma: no cover
							# < --------- Prims Algorithm --------- >
							lowerCAmelCase_  		=  int(input('Enter number of edges: ').strip())
							lowerCAmelCase_  		=  defaultdict(list)
							for _ in range(edges_number):
														lowerCAmelCase_  		=  [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))







UpperCAmelCase_							=				8.31_44_62  # Unit - J mol-1 K-1





def  __magic_name__  (				lowercase				,       lowercase				,       lowercase				)				-> float:

							"""simple docstring"""



							if moles < 0 or kelvin < 0 or volume < 0:
														raise ValueError("""Invalid inputs. Enter positive value."""				)
							return moles * kelvin * UNIVERSAL_GAS_CONSTANT / volume





def  __magic_name__  (				lowercase				,       lowercase				,       lowercase				)				-> float:

							"""simple docstring"""



							if moles < 0 or kelvin < 0 or pressure < 0:
														raise ValueError("""Invalid inputs. Enter positive value."""				)
							return moles * kelvin * UNIVERSAL_GAS_CONSTANT / pressure


if __name__ == "__main__":
							from doctest import testmod

							testmod()