




import sys
from collections import defaultdict




class 						__lowercase		:




      """simple docstring"""





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

      def      UpperCAmelCase				(				self    ,				A     )		->    Any:
         return self.node_position[vertex]

      def      UpperCAmelCase				(				self    ,				A    ,				A     )		->    Optional[int]:
         snake_case				:    List[str]           =	pos

      def      UpperCAmelCase				(				self    ,				A    ,				A    ,				A    ,				A     )		->    Optional[int]:
         if start > size // 2 - 1:
            return
         else:
            if 2 * start + 2 >= size:
               snake_case				:    Optional[Any]           =	2 * start + 1
            else:
               if heap[2 * start + 1] < heap[2 * start + 2]:
                  snake_case				:    Tuple           =	2 * start + 1
               else:
                  snake_case				:    str           =	2 * start + 2
            if heap[smallest_child] < heap[start]:
               snake_case				:    Any           =	heap[smallest_child], positions[smallest_child]
               snake_case				:    List[Any]           =	(
                   heap[start],
                   positions[start],
               )
               snake_case				:    str           =	temp, tempa

               snake_case				:    Any           =	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      UpperCAmelCase				(				self    ,				A    ,				A    ,				A    ,				A     )		->    int:
         snake_case				:    Optional[Any]           =	position[index]

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

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

      def      UpperCAmelCase				(				self    ,				A    ,				A     )		->    Tuple:
         snake_case				:    int           =	len(A     ) // 2 - 1
         for i in range(A    ,				-1    ,				-1     ):
            self.top_to_bottom(A    ,				A    ,				len(A     )    ,				A     )

      def      UpperCAmelCase				(				self    ,				A    ,				A     )		->    Optional[Any]:
         snake_case				:    str           =	positions[0]
         snake_case				:    Optional[int]           =	sys.maxsize
         self.top_to_bottom(A    ,				0    ,				len(A     )    ,				A     )
         return temp




def 						SCREAMING_SNAKE_CASE__ (   lowercase					)  ->       Union[str, Any]:
   snake_case				:    int           =	Heap()

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

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

   snake_case				:    Any           =	[]
   snake_case				:    List[str]           =	1
   snake_case				:    str           =	sys.maxsize
   for neighbor, distance in adjacency_list[0]:
      snake_case				:    Optional[Any]           =	0
      snake_case				:    List[str]           =	distance
   heap.heapify(lowercase						,lowercase					)

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


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


lowerCamelCase	:	Optional[Any]				=   {
    'configuration_roberta': ['ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RobertaConfig', 'RobertaOnnxConfig'],
    'tokenization_roberta': ['RobertaTokenizer'],
}

try:
       if not is_tokenizers_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCamelCase	:	Tuple				=   ['RobertaTokenizerFast']

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCamelCase	:	List[str]				=   [
           'ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST',
           'RobertaForCausalLM',
           'RobertaForMaskedLM',
           'RobertaForMultipleChoice',
           'RobertaForQuestionAnswering',
           'RobertaForSequenceClassification',
           'RobertaForTokenClassification',
           'RobertaModel',
           'RobertaPreTrainedModel',
       ]

try:
       if not is_tf_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCamelCase	:	Dict				=   [
           'TF_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST',
           'TFRobertaForCausalLM',
           'TFRobertaForMaskedLM',
           'TFRobertaForMultipleChoice',
           'TFRobertaForQuestionAnswering',
           'TFRobertaForSequenceClassification',
           'TFRobertaForTokenClassification',
           'TFRobertaMainLayer',
           'TFRobertaModel',
           'TFRobertaPreTrainedModel',
       ]

try:
       if not is_flax_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       lowerCamelCase	:	Any				=   [
           'FlaxRobertaForCausalLM',
           'FlaxRobertaForMaskedLM',
           'FlaxRobertaForMultipleChoice',
           'FlaxRobertaForQuestionAnswering',
           'FlaxRobertaForSequenceClassification',
           'FlaxRobertaForTokenClassification',
           'FlaxRobertaModel',
           'FlaxRobertaPreTrainedModel',
       ]


if TYPE_CHECKING:
       from .configuration_roberta import ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP, RobertaConfig, RobertaOnnxConfig
       from .tokenization_roberta import RobertaTokenizer

       try:
              if not is_tokenizers_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .tokenization_roberta_fast import RobertaTokenizerFast

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_roberta import (
                  ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
                  RobertaForCausalLM,
                  RobertaForMaskedLM,
                  RobertaForMultipleChoice,
                  RobertaForQuestionAnswering,
                  RobertaForSequenceClassification,
                  RobertaForTokenClassification,
                  RobertaModel,
                  RobertaPreTrainedModel,
              )

       try:
              if not is_tf_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_tf_roberta import (
                  TF_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
                  TFRobertaForCausalLM,
                  TFRobertaForMaskedLM,
                  TFRobertaForMultipleChoice,
                  TFRobertaForQuestionAnswering,
                  TFRobertaForSequenceClassification,
                  TFRobertaForTokenClassification,
                  TFRobertaMainLayer,
                  TFRobertaModel,
                  TFRobertaPreTrainedModel,
              )

       try:
              if not is_flax_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_flax_roberta import (
                  FlaxRobertaForCausalLM,
                  FlaxRobertaForMaskedLM,
                  FlaxRobertaForMultipleChoice,
                  FlaxRobertaForQuestionAnswering,
                  FlaxRobertaForSequenceClassification,
                  FlaxRobertaForTokenClassification,
                  FlaxRobertaModel,
                  FlaxRobertaPreTrainedModel,
              )

else:
       import sys

       lowerCamelCase	:	str				=   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





