


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))









import copy
import os
from typing import Union

from ...configuration_utils import PretrainedConfig
from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
from ...utils import logging
from ..auto import CONFIG_MAPPING


_A		       =						logging.get_logger(__name__)

_A		       =						{
    'Salesforce/instruct-blip-flan-t5': 'https://huggingface.co/Salesforce/instruct-blip-flan-t5/resolve/main/config.json',
}






class     UpperCAmelCase__       (					A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Optional[int]      =  "instructblip_vision_model"






    def __init__(			self					,   A_=1408					,   A_=6144					,   A_=39					,   A_=16					,   A_=224					,   A_=14					,   A_="gelu"					,   A_=1E-6					,   A_=0.0					,   A_=1E-10					,   A_=True					,   **A_					,   )  ->       Tuple:
         super().__init__(**A_    )

         __UpperCamelCase    							=hidden_size
         __UpperCamelCase    							=intermediate_size
         __UpperCamelCase    							=num_hidden_layers
         __UpperCamelCase    							=num_attention_heads
         __UpperCamelCase    							=patch_size
         __UpperCamelCase    							=image_size
         __UpperCamelCase    							=initializer_range
         __UpperCamelCase    							=attention_dropout
         __UpperCamelCase    							=layer_norm_eps
         __UpperCamelCase    							=hidden_act
         __UpperCamelCase    							=qkv_bias






    @classmethod
    def _a					(			cls					,   A_					,   **A_    )  ->       "PretrainedConfig":
         cls._set_token_in_kwargs(A_    )

         __UpperCamelCase							,      __UpperCamelCase    							=cls.get_config_dict(A_					,   **A_    )

         # get the vision config dict if we are loading from InstructBlipConfig
         if config_dict.get('model_type'    ) == "instructblip":
              __UpperCamelCase    							=config_dict['vision_config']

         if "model_type" in config_dict and hasattr(cls					,   'model_type'    ) and config_dict["model_type"] != cls.model_type:
              logger.warning(
                  f'You are using a model of type {config_dict["model_type"]} to instantiate a model of type '
                  f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'    )

         return cls.from_dict(A_					,   **A_    )






class     UpperCAmelCase__       (					A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Optional[Any]      =  "instructblip_qformer"






    def __init__(			self					,   A_=30522					,   A_=768					,   A_=12					,   A_=12					,   A_=3072					,   A_="gelu"					,   A_=0.1					,   A_=0.1					,   A_=512					,   A_=0.02					,   A_=1E-12					,   A_=0					,   A_="absolute"					,   A_=2					,   A_=1408					,   **A_					,   )  ->       Optional[Any]:
         super().__init__(pad_token_id=A_					,   **A_    )

         __UpperCamelCase    							=vocab_size
         __UpperCamelCase    							=hidden_size
         __UpperCamelCase    							=num_hidden_layers
         __UpperCamelCase    							=num_attention_heads
         __UpperCamelCase    							=hidden_act
         __UpperCamelCase    							=intermediate_size
         __UpperCamelCase    							=hidden_dropout_prob
         __UpperCamelCase    							=attention_probs_dropout_prob
         __UpperCamelCase    							=max_position_embeddings
         __UpperCamelCase    							=initializer_range
         __UpperCamelCase    							=layer_norm_eps
         __UpperCamelCase    							=position_embedding_type
         __UpperCamelCase    							=cross_attention_frequency
         __UpperCamelCase    							=encoder_hidden_size






    @classmethod
    def _a					(			cls					,   A_					,   **A_    )  ->       "PretrainedConfig":
         cls._set_token_in_kwargs(A_    )

         __UpperCamelCase							,      __UpperCamelCase    							=cls.get_config_dict(A_					,   **A_    )

         # get the qformer config dict if we are loading from InstructBlipConfig
         if config_dict.get('model_type'    ) == "instructblip":
              __UpperCamelCase    							=config_dict['qformer_config']

         if "model_type" in config_dict and hasattr(cls					,   'model_type'    ) and config_dict["model_type"] != cls.model_type:
              logger.warning(
                  f'You are using a model of type {config_dict["model_type"]} to instantiate a model of type '
                  f'{cls.model_type}. This is not supported for all configurations of models and can yield errors.'    )

         return cls.from_dict(A_					,   **A_    )






class     UpperCAmelCase__       (					A_		):



    """simple docstring"""






    UpperCAmelCase__						:		Optional[int]      =  "instructblip"
    UpperCAmelCase__						:		Optional[Any]      =  True






    def __init__(			self					,   A_=None					,   A_=None					,   A_=None					,   A_=32					,   **A_    )  ->       List[str]:
         super().__init__(**A_    )

         if vision_config is None:
              __UpperCamelCase    							={}
              logger.info('vision_config is None. initializing the InstructBlipVisionConfig with default values.'    )

         if qformer_config is None:
              __UpperCamelCase    							={}
              logger.info('qformer_config is None. Initializing the InstructBlipQFormerConfig with default values.'    )

         if text_config is None:
              __UpperCamelCase    							={}
              logger.info('text_config is None. Initializing the text config with default values (`OPTConfig`).'    )

         __UpperCamelCase    							=InstructBlipVisionConfig(**A_    )
         __UpperCamelCase    							=InstructBlipQFormerConfig(**A_    )
         __UpperCamelCase    							=text_config['model_type'] if 'model_type' in text_config else 'opt'
         __UpperCamelCase    							=CONFIG_MAPPING[text_model_type](**A_    )

         __UpperCamelCase    							=self.text_config.tie_word_embeddings
         __UpperCamelCase    							=self.text_config.is_encoder_decoder

         __UpperCamelCase    							=num_query_tokens
         __UpperCamelCase    							=self.vision_config.hidden_size
         __UpperCamelCase    							=self.text_config.model_type in MODEL_FOR_CAUSAL_LM_MAPPING_NAMES
         __UpperCamelCase    							=1.0
         __UpperCamelCase    							=0.02






    @classmethod
    def _a					(			cls					,   A_					,   A_					,   A_					,   **A_					,   )  ->       Optional[Any]:
         return cls(
             vision_config=vision_config.to_dict()					,   qformer_config=qformer_config.to_dict()					,   text_config=text_config.to_dict()					,   **A_					,   )






    def _a					(			self    )  ->       Optional[Any]:
         __UpperCamelCase    							=copy.deepcopy(self.__dict__    )
         __UpperCamelCase    							=self.vision_config.to_dict()
         __UpperCamelCase    							=self.qformer_config.to_dict()
         __UpperCamelCase    							=self.text_config.to_dict()
         __UpperCamelCase    							=self.__class__.model_type
         return output





