


'''simple docstring'''



# Imports
import numpy as np





class   UpperCAmelCase_    :





    """simple docstring"""






    def __init__(				self     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None      )							->	str:
         self.set_matricies(red=SCREAMING_SNAKE_CASE_     ,	green=SCREAMING_SNAKE_CASE_     ,	blue=SCREAMING_SNAKE_CASE_     ,	red_edge=SCREAMING_SNAKE_CASE_     ,	nir=SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None      )							->	Any:
         if red is not None:
              __lowerCamelCase  :      Dict														=						red
         if green is not None:
              __lowerCamelCase  :      List[Any]														=						green
         if blue is not None:
              __lowerCamelCase  :      int														=						blue
         if red_edge is not None:
              __lowerCamelCase  :      Optional[int]														=						red_edge
         if nir is not None:
              __lowerCamelCase  :      Any														=						nir
         return True







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_=""     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None      )							->	Optional[Any]:
         self.set_matricies(red=SCREAMING_SNAKE_CASE_     ,	green=SCREAMING_SNAKE_CASE_     ,	blue=SCREAMING_SNAKE_CASE_     ,	red_edge=SCREAMING_SNAKE_CASE_     ,	nir=SCREAMING_SNAKE_CASE_      )
         __lowerCamelCase  :      List[Any]														=						{
             'ARVI2': self.arvaa,
             'CCCI': self.ccci,
             'CVI': self.cvi,
             'GLI': self.gli,
             'NDVI': self.ndvi,
             'BNDVI': self.bndvi,
             'redEdgeNDVI': self.red_edge_ndvi,
             'GNDVI': self.gndvi,
             'GBNDVI': self.gbndvi,
             'GRNDVI': self.grndvi,
             'RBNDVI': self.rbndvi,
             'PNDVI': self.pndvi,
             'ATSAVI': self.atsavi,
             'BWDRVI': self.bwdrvi,
             'CIgreen': self.ci_green,
             'CIrededge': self.ci_rededge,
             'CI': self.ci,
             'CTVI': self.ctvi,
             'GDVI': self.gdvi,
             'EVI': self.evi,
             'GEMI': self.gemi,
             'GOSAVI': self.gosavi,
             'GSAVI': self.gsavi,
             'Hue': self.hue,
             'IVI': self.ivi,
             'IPVI': self.ipvi,
             'I': self.i,
             'RVI': self.rvi,
             'MRVI': self.mrvi,
             'MSAVI': self.m_savi,
             'NormG': self.norm_g,
             'NormNIR': self.norm_nir,
             'NormR': self.norm_r,
             'NGRDI': self.ngrdi,
             'RI': self.ri,
             'S': self.s,
             'IF': self._if,
             'DVI': self.dvi,
             'TVI': self.tvi,
             'NDRE': self.ndre,
         }

         try:
              return funcs[index]()
         except KeyError:
              print('Index not in the list!'      )
              return False







    def  lowercase_							(				self      )							->	Optional[Any]:
         return -0.1_8 + (1.1_7 * ((self.nir - self.red) / (self.nir + self.red)))







    def  lowercase_							(				self      )							->	Dict:
         return ((self.nir - self.redEdge) / (self.nir + self.redEdge)) / (
             (self.nir - self.red) / (self.nir + self.red)
         )







    def  lowercase_							(				self      )							->	Any:
         return self.nir * (self.red / (self.green**2))







    def  lowercase_							(				self      )							->	Optional[Any]:
         return (2 * self.green - self.red - self.blue) / (
             2 * self.green + self.red + self.blue
         )







    def  lowercase_							(				self      )							->	Union[str, Any]:
         return (self.nir - self.red) / (self.nir + self.red)







    def  lowercase_							(				self      )							->	Optional[int]:
         return (self.nir - self.blue) / (self.nir + self.blue)







    def  lowercase_							(				self      )							->	Optional[int]:
         return (self.redEdge - self.red) / (self.redEdge + self.red)







    def  lowercase_							(				self      )							->	Any:
         return (self.nir - self.green) / (self.nir + self.green)







    def  lowercase_							(				self      )							->	int:
         return (self.nir - (self.green + self.blue)) / (
             self.nir + (self.green + self.blue)
         )







    def  lowercase_							(				self      )							->	List[Any]:
         return (self.nir - (self.green + self.red)) / (
             self.nir + (self.green + self.red)
         )







    def  lowercase_							(				self      )							->	List[Any]:
         return (self.nir - (self.blue + self.red)) / (self.nir + (self.blue + self.red))







    def  lowercase_							(				self      )							->	str:
         return (self.nir - (self.green + self.red + self.blue)) / (
             self.nir + (self.green + self.red + self.blue)
         )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_=0.0_8     ,	SCREAMING_SNAKE_CASE_=1.2_2     ,	SCREAMING_SNAKE_CASE_=0.0_3      )							->	str:
         return a * (
             (self.nir - a * self.red - b)
             / (a * self.nir + self.red - a * b + x * (1 + a**2))
         )







    def  lowercase_							(				self      )							->	Any:
         return (0.1 * self.nir - self.blue) / (0.1 * self.nir + self.blue)







    def  lowercase_							(				self      )							->	Optional[Any]:
         return (self.nir / self.green) - 1







    def  lowercase_							(				self      )							->	Tuple:
         return (self.nir / self.redEdge) - 1







    def  lowercase_							(				self      )							->	List[Any]:
         return (self.red - self.blue) / self.red







    def  lowercase_							(				self      )							->	Optional[Any]:
         __lowerCamelCase  :      Any														=						self.ndvi()
         return ((ndvi + 0.5) / (abs(ndvi + 0.5      ))) * (abs(ndvi + 0.5      ) ** (1 / 2))







    def  lowercase_							(				self      )							->	List[str]:
         return self.nir - self.green







    def  lowercase_							(				self      )							->	Tuple:
         return 2.5 * (
             (self.nir - self.red) / (self.nir + 6 * self.red - 7.5 * self.blue + 1)
         )







    def  lowercase_							(				self      )							->	Union[str, Any]:
         __lowerCamelCase  :      str														=						(2 * (self.nir**2 - self.red**2) + 1.5 * self.nir + 0.5 * self.red) / (
             self.nir + self.red + 0.5
         )
         return n * (1 - 0.2_5 * n) - (self.red - 0.1_2_5) / (1 - self.red)







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_=0.1_6      )							->	Tuple:
         return (self.nir - self.green) / (self.nir + self.green + y)







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_=0.5      )							->	Optional[int]:
         return ((self.nir - self.green) / (self.nir + self.green + n)) * (1 + n)







    def  lowercase_							(				self      )							->	str:
         return np.arctan(
             ((2 * self.red - self.green - self.blue) / 3_0.5) * (self.green - self.blue)      )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_=None     ,	SCREAMING_SNAKE_CASE_=None      )							->	int:
         return (self.nir - b) / (a * self.red)







    def  lowercase_							(				self      )							->	Union[str, Any]:
         return (self.nir / ((self.nir + self.red) / 2)) * (self.ndvi() + 1)







    def  lowercase_							(				self      )							->	int:
         return (self.red + self.green + self.blue) / 3_0.5







    def  lowercase_							(				self      )							->	Optional[int]:
         return self.nir / self.red







    def  lowercase_							(				self      )							->	Dict:
         return (self.rvi() - 1) / (self.rvi() + 1)







    def  lowercase_							(				self      )							->	Dict:
         return (
             (2 * self.nir + 1)
             - ((2 * self.nir + 1) ** 2 - 8 * (self.nir - self.red)) ** (1 / 2)
         ) / 2







    def  lowercase_							(				self      )							->	Optional[int]:
         return self.green / (self.nir + self.red + self.green)







    def  lowercase_							(				self      )							->	List[str]:
         return self.nir / (self.nir + self.red + self.green)







    def  lowercase_							(				self      )							->	List[str]:
         return self.red / (self.nir + self.red + self.green)







    def  lowercase_							(				self      )							->	List[Any]:
         return (self.green - self.red) / (self.green + self.red)







    def  lowercase_							(				self      )							->	List[str]:
         return (self.red - self.green) / (self.red + self.green)







    def  lowercase_							(				self      )							->	Any:
         __lowerCamelCase  :      Union[str, Any]														=						np.max([np.max(self.red      ), np.max(self.green      ), np.max(self.blue      )]      )
         __lowerCamelCase  :      Optional[Any]														=						np.min([np.min(self.red      ), np.min(self.green      ), np.min(self.blue      )]      )
         return (max_value - min_value) / max_value







    def  lowercase_							(				self      )							->	Optional[Any]:
         return (2 * self.red - self.green - self.blue) / (self.green - self.blue)







    def  lowercase_							(				self      )							->	Any:
         return self.nir / self.red







    def  lowercase_							(				self      )							->	str:
         return (self.ndvi() + 0.5) ** (1 / 2)







    def  lowercase_							(				self      )							->	Optional[int]:
         return (self.nir - self.redEdge) / (self.nir + self.redEdge)










'''simple docstring'''



import sys
from collections import defaultdict





class   UpperCAmelCase_    :





    """simple docstring"""






    def __init__(				self      )							->	int:
         __lowerCamelCase  :      Any														=						[]







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_      )							->	Any:
         return self.node_position[vertex]







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Tuple:
         __lowerCamelCase  :      Optional[int]														=						pos







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

                   __lowerCamelCase  :      Dict														=						self.get_position(positions[smallest_child]      )
                   self.set_position(
                       positions[smallest_child]     ,	self.get_position(positions[start]      )      )
                   self.set_position(positions[start]     ,	SCREAMING_SNAKE_CASE_      )

                   self.top_to_bottom(SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Any:
         __lowerCamelCase  :      Any														=						position[index]

         while index != 0:
              __lowerCamelCase  :      Union[str, Any]														=						int((index - 2) / 2      ) if index % 2 == 0 else int((index - 1) / 2      )

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







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Optional[int]:
         __lowerCamelCase  :      Optional[int]														=						len(SCREAMING_SNAKE_CASE_      ) // 2 - 1
         for i in range(SCREAMING_SNAKE_CASE_     ,	-1     ,	-1      ):
              self.top_to_bottom(SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	len(SCREAMING_SNAKE_CASE_      )     ,	SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	List[Any]:
         __lowerCamelCase  :      Any														=						positions[0]
         __lowerCamelCase  :      Union[str, Any]														=						sys.maxsize
         self.top_to_bottom(SCREAMING_SNAKE_CASE_     ,	0     ,	len(SCREAMING_SNAKE_CASE_      )     ,	SCREAMING_SNAKE_CASE_      )
         return temp







def      UpperCAmelCase__   (      UpperCAmelCase_       :							Optional[int]				)	->						str:
     __lowerCamelCase  :      List[Any]														=						Heap()

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

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

     __lowerCamelCase  :      Tuple														=						[]
     __lowerCamelCase  :      Dict														=						1
     __lowerCamelCase  :      str														=						sys.maxsize
     for neighbor, distance in adjacency_list[0]:
          __lowerCamelCase  :      Any														=						0
          __lowerCamelCase  :      Any														=						distance
     heap.heapify(UpperCAmelCase_ ,       UpperCAmelCase_				)

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


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






