


import sys
from collections import defaultdict







class 		_snake_case  :




 def __init__(		self   ):
       a						:Optional[Any]										=	[]




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase   ):
       return self.node_position[vertex]




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase ,  _lowerCamelCase   ):
       a						:Tuple										=	pos




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

                   a						:int										=	self.get_position(positions[smallest_child]   )
                   self.set_position(
                       positions[smallest_child] ,  self.get_position(positions[start]   )   )
                   self.set_position(positions[start] ,  _lowerCamelCase   )

                   self.top_to_bottom(_lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase   )




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase ,  _lowerCamelCase   ):
       a						:str										=	position[index]

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

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




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase ,  _lowerCamelCase   ):
       a						:List[str]										=	len(_lowerCamelCase   ) // 2 - 1
       for i in range(_lowerCamelCase ,  -1 ,  -1   ):
             self.top_to_bottom(_lowerCamelCase ,  _lowerCamelCase ,  len(_lowerCamelCase   ) ,  _lowerCamelCase   )




 def 	SCREAMING_SNAKE_CASE__    (		self ,  _lowerCamelCase ,  _lowerCamelCase   ):
       a						:int										=	positions[0]
       a						:Dict										=	sys.maxsize
       self.top_to_bottom(_lowerCamelCase ,  0 ,  len(_lowerCamelCase   ) ,  _lowerCamelCase   )
       return temp







def     __lowerCamelCase						(			UpperCAmelCase_						:		Tuple						):




      """simple docstring"""





      a						:str										=	Heap()

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

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

      a						:Optional[Any]										=	[]
      a						:Any										=	1
      a						:List[Any]										=	sys.maxsize
      for neighbor, distance in adjacency_list[0]:
            a						:Optional[int]										=	0
            a						:int										=	distance
      heap.heapify(UpperCAmelCase_			,  UpperCAmelCase_						)

      for _ in range(1			,  len(UpperCAmelCase_						)						):
            a						:Optional[int]										=	heap.delete_minimum(UpperCAmelCase_			,  UpperCAmelCase_						)
            if visited[vertex] == 0:
                  tree_edges.append((nbr_tv[vertex], vertex)						)
                  a						:Tuple										=	1
                  for neighbor, distance in adjacency_list[vertex]:
                        if (
                            visited[neighbor] == 0
                            and distance < distance_tv[heap.get_position(UpperCAmelCase_						)]
                        ):
                              a						:Dict										=	distance
                              heap.bottom_to_top(
                                  UpperCAmelCase_			,  heap.get_position(UpperCAmelCase_						)			,  UpperCAmelCase_			,  UpperCAmelCase_						)
                              a						:Optional[int]										=	vertex
      return tree_edges


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









from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


snake_case    :   Any	    =					{'''configuration_van''': ['''VAN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''VanConfig''']}


try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case    :   Union[str, Any]	    =					[
         '''VAN_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''VanForImageClassification''',
         '''VanModel''',
         '''VanPreTrainedModel''',
     ]

if TYPE_CHECKING:
     from .configuration_van import VAN_PRETRAINED_CONFIG_ARCHIVE_MAP, VanConfig

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_van import (
              VAN_PRETRAINED_MODEL_ARCHIVE_LIST,
              VanForImageClassification,
              VanModel,
              VanPreTrainedModel,
          )

else:
     import sys

     snake_case    :   Optional[Any]	    =					_LazyModule(__name__, globals()['''__file__'''], _import_structure)





