





import sys
from collections import defaultdict


class        __SCREAMING_SNAKE_CASE      :







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







       def 						__lowerCamelCase   (				self					:     Optional[int]		, A					:     List[Any]      )       ->Any:
          return self.node_position[vertex]







       def 						__lowerCamelCase   (				self					:     Dict		, A					:     Tuple		, A					:     List[str]      )       ->Dict:
          lowerCamelCase__       :						Union[str, Any]        =							pos







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

                lowerCamelCase__       :						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 						__lowerCamelCase   (				self					:     Optional[Any]		, A					:     Tuple		, A					:     Any		, A					:     str		, A					:     Any      )       ->Tuple:
          lowerCamelCase__       :						Tuple        =							position[index]

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

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







       def 						__lowerCamelCase   (				self					:     List[str]		, A					:     List[Any]		, A					:     Tuple      )       ->Optional[int]:
          lowerCamelCase__       :						List[str]        =							len(A      ) // 2 - 1
          for i in range(A		, -1		, -1      ):
             self.top_to_bottom(A		, A		, len(A      )		, A      )







       def 						__lowerCamelCase   (				self					:     List[str]		, A					:     Dict		, A					:     Optional[int]      )       ->Union[str, Any]:
          lowerCamelCase__       :						int        =							positions[0]
          lowerCamelCase__       :						Any        =							sys.maxsize
          self.top_to_bottom(A		, 0		, len(A      )		, A      )
          return temp



def 	_a						(   UpperCAmelCase					)    ->    Tuple:







   """simple docstring"""
   lowerCamelCase__       :						List[str]        =							Heap()

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

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

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

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


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










def 	_a						(   UpperCAmelCase					)    ->    int:







   """simple docstring"""

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


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



