
import sys
from collections import defaultdict



class 		UpperCamelCase__  :
   def __init__(self			: Optional[Any]       ):
    __a			:  str		    =  []
   def 				lowerCAmelCase      (self			: int ,    snake_case_			: List[Any]       ):
    return self.node_position[vertex]
   def 				lowerCAmelCase      (self			: List[str] ,    snake_case_			: str ,    snake_case_			: List[str]       ):
    __a			:  Any		    =  pos
   def 				lowerCAmelCase      (self			: str ,    snake_case_			: Any ,    snake_case_			: Optional[Any] ,    snake_case_			: Dict ,    snake_case_			: List[str]       ):
    if start > size // 2 - 1:
     return
    else:
     if 2 * start + 2 >= size:
      __a			:  str		    =  2 * start + 1
     else:
      if heap[2 * start + 1] < heap[2 * start + 2]:
       __a			:  Union[str, Any]		    =  2 * start + 1
      else:
       __a			:  Dict		    =  2 * start + 2
     if heap[smallest_child] < heap[start]:
      __a			:  List[Any]		    =  heap[smallest_child], positions[smallest_child]
      __a			:  List[str]		    =  (
          heap[start],
          positions[start],
      )
      __a			:  Any		    =  temp, tempa

      __a			:  Dict		    =  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			: Optional[Any] ,    snake_case_			: str ,    snake_case_			: Optional[int] ,    snake_case_			: int ,    snake_case_			: int       ):
    __a			:  Any		    =  position[index]

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

     if val < heap[parent]:
      __a			:  List[Any]		    =  heap[parent]
      __a			:  Dict		    =  position[parent]
      self.set_position(position[parent] ,    snake_case_       )
     else:
      __a			:  Dict		    =  val
      __a			:  Tuple		    =  temp
      self.set_position(snake_case_ ,    snake_case_       )
      break
     __a			:  Tuple		    =  parent
    else:
     __a			:  Optional[Any]		    =  val
     __a			:  List[str]		    =  temp
     self.set_position(snake_case_ ,    0       )
   def 				lowerCAmelCase      (self			: int ,    snake_case_			: Union[str, Any] ,    snake_case_			: Optional[int]       ):
    __a			:  List[str]		    =  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			: Tuple ,    snake_case_			: int ,    snake_case_			: List[str]       ):
    __a			:  Optional[Any]		    =  positions[0]
    __a			:  Dict		    =  sys.maxsize
    self.top_to_bottom(snake_case_ ,    0 ,    len(snake_case_       ) ,    snake_case_       )
    return temp





def        __UpperCamelCase(    lowerCAmelCase__							:    Optional[int]  ):
 __a			:  Tuple		    =  Heap()

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

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

 __a			:  List[str]		    =  []
 __a			:  Tuple		    =  1
 __a			:  Tuple		    =  sys.maxsize
 for neighbor, distance in adjacency_list[0]:
  __a			:  Dict		    =  0
  __a			:  Optional[int]		    =  distance
 heap.heapify(lowerCAmelCase__  ,       lowerCAmelCase__  )

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


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


lowercase__          ={
    'configuration_layoutlmv2': ['LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LayoutLMv2Config'],
    'processing_layoutlmv2': ['LayoutLMv2Processor'],
    'tokenization_layoutlmv2': ['LayoutLMv2Tokenizer'],
}

try:
      if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase__          =['LayoutLMv2TokenizerFast']

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase__          =['LayoutLMv2FeatureExtractor']
      lowercase__          =['LayoutLMv2ImageProcessor']

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase__          =[
          'LAYOUTLMV2_PRETRAINED_MODEL_ARCHIVE_LIST',
          'LayoutLMv2ForQuestionAnswering',
          'LayoutLMv2ForSequenceClassification',
          'LayoutLMv2ForTokenClassification',
          'LayoutLMv2Layer',
          'LayoutLMv2Model',
          'LayoutLMv2PreTrainedModel',
      ]

if TYPE_CHECKING:
      from .configuration_layoutlmva import LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP, LayoutLMvaConfig
      from .processing_layoutlmva import LayoutLMvaProcessor
      from .tokenization_layoutlmva import LayoutLMvaTokenizer

      try:
            if not is_tokenizers_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .tokenization_layoutlmva_fast import LayoutLMvaTokenizerFast

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_layoutlmva import LayoutLMvaFeatureExtractor, LayoutLMvaImageProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_layoutlmva import (
                LAYOUTLMV2_PRETRAINED_MODEL_ARCHIVE_LIST,
                LayoutLMvaForQuestionAnswering,
                LayoutLMvaForSequenceClassification,
                LayoutLMvaForTokenClassification,
                LayoutLMvaLayer,
                LayoutLMvaModel,
                LayoutLMvaPreTrainedModel,
            )
else:
      import sys

      lowercase__          =_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
