





'''simple docstring'''






import sys
from collections import defaultdict




class  _A :

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


					"""simple docstring"""

					__snake_case					:      Optional[Any]							      =     []

		def 	lowercase__     (   self					:   int  ,      __magic_name__					:   List[Any]			)					->    Dict:


					"""simple docstring"""

					return self.node_position[vertex]

		def 	lowercase__     (   self					:   Optional[int]  ,      __magic_name__					:   List[str]  ,      __magic_name__					:   Optional[Any]			)					->    List[Any]:


					"""simple docstring"""

					__snake_case					:      List[str]							      =     pos

		def 	lowercase__     (   self					:   int  ,      __magic_name__					:   int  ,      __magic_name__					:   int  ,      __magic_name__					:   Any  ,      __magic_name__					:   str			)					->    Optional[Any]:


					"""simple docstring"""

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

											__snake_case					:      Tuple							      =     self.get_position(positions[smallest_child]			)
											self.set_position(
											    positions[smallest_child]  ,      self.get_position(positions[start]			)			)
											self.set_position(positions[start]  ,      __magic_name__			)

											self.top_to_bottom(__magic_name__  ,      __magic_name__  ,      __magic_name__  ,      __magic_name__			)

		def 	lowercase__     (   self					:   str  ,      __magic_name__					:   str  ,      __magic_name__					:   List[str]  ,      __magic_name__					:   Any  ,      __magic_name__					:   Union[str, Any]			)					->    int:


					"""simple docstring"""

					__snake_case					:      List[Any]							      =     position[index]

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

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

		def 	lowercase__     (   self					:   Optional[int]  ,      __magic_name__					:   Dict  ,      __magic_name__					:   Tuple			)					->    List[str]:


					"""simple docstring"""

					__snake_case					:      Any							      =     len(__magic_name__			) // 2 - 1
					for i in range(__magic_name__  ,      -1  ,      -1			):
								self.top_to_bottom(__magic_name__  ,      __magic_name__  ,      len(__magic_name__			)  ,      __magic_name__			)

		def 	lowercase__     (   self					:   List[Any]  ,      __magic_name__					:   List[Any]  ,      __magic_name__					:   List[Any]			)					->    List[str]:


					"""simple docstring"""

					__snake_case					:      Optional[Any]							      =     positions[0]
					__snake_case					:      Optional[int]							      =     sys.maxsize
					self.top_to_bottom(__magic_name__  ,      0  ,      len(__magic_name__			)  ,      __magic_name__			)
					return temp







def 					_a						(       _lowerCamelCase ) ->				List[Any]:



			"""simple docstring"""


			__snake_case					:      List[Any]							      =     Heap()

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

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

			__snake_case					:      Optional[int]							      =     []
			__snake_case					:      List[str]							      =     1
			__snake_case					:      Any							      =     sys.maxsize
			for neighbor, distance in adjacency_list[0]:
						__snake_case					:      List[str]							      =     0
						__snake_case					:      List[Any]							      =     distance
			heap.heapify(_lowerCamelCase    ,	_lowerCamelCase )

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


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



			"""simple docstring"""


			if not isinstance(_lowerCamelCase    ,	_lowerCamelCase ):
						raise TypeError("""only integers accepted as input""" )
			else:
						__snake_case					:      List[Any]							      =     str(abs(_lowerCamelCase ) )
						__snake_case					:      Union[str, Any]							      =     [list(_lowerCamelCase ) for char in range(len(_lowerCamelCase ) )]
						for index in range(len(_lowerCamelCase ) ):
									num_transpositions[index].pop(_lowerCamelCase )
						return max(
						    int("""""".join(list(_lowerCamelCase ) ) ) for transposition in num_transpositions )


if __name__ == "__main__":
	__import__("doctest").testmod()


