



'''simple docstring'''





import sys
from collections import defaultdict







class     UpperCAmelCase_       :
    """simple docstring"""







    def __init__(    self					:     Any						):
          snake_case__  :    Union[str, Any]    						=      []




    def lowerCamelCase       (    self					:     str ,     snake_case_					:     Any						):
          return self.node_position[vertex]




    def lowerCamelCase       (    self					:     Dict ,     snake_case_					:     Optional[int] ,     snake_case_					:     Optional[Any]						):
          snake_case__  :    Optional[Any]    						=      pos




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

                      snake_case__  :    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 lowerCamelCase       (    self					:     Tuple ,     snake_case_					:     Any ,     snake_case_					:     Optional[Any] ,     snake_case_					:     Tuple ,     snake_case_					:     str						):
          snake_case__  :    Union[str, 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__  :    List[Any]    						=      heap[parent]
                      snake_case__  :    str    						=      position[parent]
                      self.set_position(position[parent] ,     __snake_case						)
                else:
                      snake_case__  :    Optional[Any]    						=      val
                      snake_case__  :    Dict    						=      temp
                      self.set_position(__snake_case ,     __snake_case						)
                      break
                snake_case__  :    Optional[int]    						=      parent
          else:
                snake_case__  :    Any    						=      val
                snake_case__  :    Optional[int]    						=      temp
                self.set_position(__snake_case ,     0						)




    def lowerCamelCase       (    self					:     Optional[Any] ,     snake_case_					:     Union[str, Any] ,     snake_case_					:     List[Any]						):
          snake_case__  :    Tuple    						=      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 lowerCamelCase       (    self					:     Dict ,     snake_case_					:     Optional[Any] ,     snake_case_					:     int						):
          snake_case__  :    List[Any]    						=      positions[0]
          snake_case__  :    Optional[int]    						=      sys.maxsize
          self.top_to_bottom(__snake_case ,     0 ,     len(__snake_case						) ,     __snake_case						)
          return temp





def 						__snake_case(				_lowerCAmelCase		)		-> str:
      snake_case__  :    Union[str, Any]    						=      Heap()

      snake_case__  :    str    						=      [0] * len(_lowerCAmelCase		)
      snake_case__  :    str    						=      [-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__  :    Optional[int]    						=      []  # Heap of Distance of vertices from their neighboring vertex
      snake_case__  :    List[str]    						=      []

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

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

      for _ in range(1     ,   len(_lowerCAmelCase		)		):
            snake_case__  :    str    						=      heap.delete_minimum(_lowerCAmelCase     ,   _lowerCAmelCase		)
            if visited[vertex] == 0:
                  tree_edges.append((nbr_tv[vertex], vertex)		)
                  snake_case__  :    Optional[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__  :    Optional[Any]    						=      vertex
      return tree_edges


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






from __future__ import annotations


def  snake_case_     (					_lowerCAmelCase  :						list[int | float]   ,      _lowerCAmelCase  :						int   ,      _lowerCAmelCase  :						int  )      ->   int | float:
							if len(_lowerCAmelCase  ) == 0:
														raise ValueError('''find_max() arg is an empty sequence'''  )
							if (
							    left >= len(_lowerCAmelCase  )
							    or left < -len(_lowerCAmelCase  )
							    or right >= len(_lowerCAmelCase  )
							    or right < -len(_lowerCAmelCase  )
							):
														raise IndexError('''list index out of range'''  )
							if left == right:
														return nums[left]
							UpperCAmelCase :       List[Any] 							=		(left + right) >> 1  # the middle
							UpperCAmelCase :       Optional[Any] 							=		find_max(_lowerCAmelCase   ,      _lowerCAmelCase   ,      _lowerCAmelCase  )  # find max in range[left, mid]
							UpperCAmelCase :       Dict 							=		find_max(_lowerCAmelCase   ,      mid + 1   ,      _lowerCAmelCase  )  # find max in range[mid + 1, right]

							return left_max if left_max >= right_max else right_max


if __name__ == "__main__":
						import doctest

						doctest.testmod(verbose=True)





