

"""simple docstring"""




import sys
from collections import defaultdict







class   __lowercase      :

  def __init__(	self		:      List[str]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	Optional[Any]        =       []

  def  __lowercase							(	self		:      Union[str, Any]       ,A		:      Optional[Any]     ):






   '''simple docstring'''
   return self.node_position[vertex]

  def  __lowercase							(	self		:      str       ,A		:      int       ,A		:      Optional[Any]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	str        =       pos

  def  __lowercase							(	self		:      Union[str, Any]       ,A		:      List[Any]       ,A		:      Optional[int]       ,A		:      Any       ,A		:      List[Any]     ):






   '''simple docstring'''

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

     UpperCAmelCase__       :	List[str]        =       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  __lowercase							(	self		:      List[Any]       ,A		:      List[Any]       ,A		:      List[Any]       ,A		:      Tuple       ,A		:      Tuple     ):






   '''simple docstring'''
   UpperCAmelCase__       :	List[str]        =       position[index]

   while index != 0:
    UpperCAmelCase__       :	int        =       int((index - 2) / 2     ) if index % 2 == 0 else int((index - 1) / 2     )

    if val < heap[parent]:
     UpperCAmelCase__       :	str        =       heap[parent]
     UpperCAmelCase__       :	str        =       position[parent]
     self.set_position(position[parent]       ,a__     )
    else:
     UpperCAmelCase__       :	str        =       val
     UpperCAmelCase__       :	Tuple        =       temp
     self.set_position(a__       ,a__     )
     break
    UpperCAmelCase__       :	List[str]        =       parent
   else:
    UpperCAmelCase__       :	int        =       val
    UpperCAmelCase__       :	Any        =       temp
    self.set_position(a__       ,0     )

  def  __lowercase							(	self		:      str       ,A		:      Dict       ,A		:      Dict     ):






   '''simple docstring'''
   UpperCAmelCase__       :	Optional[Any]        =       len(a__     ) // 2 - 1
   for i in range(a__       ,-1       ,-1     ):
    self.top_to_bottom(a__       ,a__       ,len(a__     )       ,a__     )




  def  __lowercase							(	self		:      List[Any]       ,A		:      int       ,A		:      Optional[Any]     ):






   '''simple docstring'''
   UpperCAmelCase__       :	Union[str, Any]        =       positions[0]
   UpperCAmelCase__       :	Tuple        =       sys.maxsize
   self.top_to_bottom(a__       ,0       ,len(a__     )       ,a__     )
   return temp







def 	lowerCAmelCase    (       __UpperCamelCase   ):
 '''simple docstring'''





 UpperCAmelCase__       :	Optional[Any]        =       Heap()

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

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

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

 for _ in range(1				,     len(lowerCamelCase_   )   ):
  UpperCAmelCase__       :	int        =       heap.delete_minimum(lowerCamelCase_				,     lowerCamelCase_   )
  if visited[vertex] == 0:
   tree_edges.append((nbr_tv[vertex], vertex)   )
   UpperCAmelCase__       :	Dict        =       1
   for neighbor, distance in adjacency_list[vertex]:
    if (
        visited[neighbor] == 0
        and distance < distance_tv[heap.get_position(lowerCamelCase_   )]
    ):
     UpperCAmelCase__       :	Optional[int]        =       distance
     heap.bottom_to_top(
         lowerCamelCase_				,     heap.get_position(lowerCamelCase_   )				,     lowerCamelCase_				,     lowerCamelCase_   )
     UpperCAmelCase__       :	str        =       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        UpperCAmelCase_ (  lowerCamelCase_			):







 """simple docstring"""


 return number & 1 == 0


if __name__ == "__main__":
     import doctest

     doctest.testmod()





