


import sys
from collections import defaultdict






class     UpperCAmelCase__       :



    """simple docstring"""






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






    def _a					(			self					,   A_    )  ->       List[Any]:
         return self.node_position[vertex]






    def _a					(			self					,   A_					,   A_    )  ->       List[Any]:
         __UpperCamelCase    							=pos






    def _a					(			self					,   A_					,   A_					,   A_					,   A_    )  ->       List[Any]:
         if start > size // 2 - 1:
              return
         else:
              if 2 * start + 2 >= size:
                   __UpperCamelCase    							=2 * start + 1
              else:
                   if heap[2 * start + 1] < heap[2 * start + 2]:
                        __UpperCamelCase    							=2 * start + 1
                   else:
                        __UpperCamelCase    							=2 * start + 2
              if heap[smallest_child] < heap[start]:
                   __UpperCamelCase							,      __UpperCamelCase    							=heap[smallest_child], positions[smallest_child]
                   __UpperCamelCase							,      __UpperCamelCase    							=(
                       heap[start],
                       positions[start],
                   )
                   __UpperCamelCase							,      __UpperCamelCase    							=temp, tempa

                   __UpperCamelCase    							=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 _a					(			self					,   A_					,   A_					,   A_					,   A_    )  ->       int:
         __UpperCamelCase    							=position[index]

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

              if val < heap[parent]:
                   __UpperCamelCase    							=heap[parent]
                   __UpperCamelCase    							=position[parent]
                   self.set_position(position[parent]					,   A_    )
              else:
                   __UpperCamelCase    							=val
                   __UpperCamelCase    							=temp
                   self.set_position(A_					,   A_    )
                   break
              __UpperCamelCase    							=parent
         else:
              __UpperCamelCase    							=val
              __UpperCamelCase    							=temp
              self.set_position(A_					,   0    )






    def _a					(			self					,   A_					,   A_    )  ->       List[str]:
         __UpperCamelCase    							=len(A_    ) // 2 - 1
         for i in range(A_					,   -1					,   -1    ):
              self.top_to_bottom(A_					,   A_					,   len(A_    )					,   A_    )






    def _a					(			self					,   A_					,   A_    )  ->       str:
         __UpperCamelCase    							=positions[0]
         __UpperCamelCase    							=sys.maxsize
         self.top_to_bottom(A_					,   0					,   len(A_    )					,   A_    )
         return temp

def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					Dict				):
     __UpperCamelCase    							=Heap()

     __UpperCamelCase    							=[0] * len(SCREAMING_SNAKE_CASE__				)
     __UpperCamelCase    							=[-1] * len(SCREAMING_SNAKE_CASE__				)  # Neighboring Tree Vertex of selected vertex
     # Minimum Distance of explored vertex with neighboring vertex of partial tree
     # formed in graph
     __UpperCamelCase    							=[]  # Heap of Distance of vertices from their neighboring vertex
     __UpperCamelCase    							=[]

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

     __UpperCamelCase    							=[]
     __UpperCamelCase    							=1
     __UpperCamelCase    							=sys.maxsize
     for neighbor, distance in adjacency_list[0]:
          __UpperCamelCase    							=0
          __UpperCamelCase    							=distance
     heap.heapify(SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				)

     for _ in range(1			,     len(SCREAMING_SNAKE_CASE__				)				):
          __UpperCamelCase    							=heap.delete_minimum(SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				)
          if visited[vertex] == 0:
               tree_edges.append((nbr_tv[vertex], vertex)				)
               __UpperCamelCase    							=1
               for neighbor, distance in adjacency_list[vertex]:
                    if (
                        visited[neighbor] == 0
                        and distance < distance_tv[heap.get_position(SCREAMING_SNAKE_CASE__				)]
                    ):
                         __UpperCamelCase    							=distance
                         heap.bottom_to_top(
                             SCREAMING_SNAKE_CASE__			,     heap.get_position(SCREAMING_SNAKE_CASE__				)			,     SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				)
                         __UpperCamelCase    							=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'''




def 							lowerCamelCase	(      UpperCAmelCase__       :					int      ,      UpperCAmelCase__       :					int )			->      bool:
							return numa ^ numa < 0


if __name__ == "__main__":
						import doctest

						doctest.testmod()





