




import sys
from collections import defaultdict
class 			_UpperCamelCase      :
      def __init__(			self   :List[Any]      )     ->			str:
       UpperCAmelCase__							 =						[]
      def 	UpperCAmelCase_						(			self   :str ,      lowerCamelCase   :Union[str, Any]      )     ->			Union[str, Any]:
       return self.node_position[vertex]
      def 	UpperCAmelCase_						(			self   :Union[str, Any] ,      lowerCamelCase   :Optional[int] ,      lowerCamelCase   :Tuple      )     ->			Tuple:
       UpperCAmelCase__							 =						pos
      def 	UpperCAmelCase_						(			self   :Union[str, Any] ,      lowerCamelCase   :int ,      lowerCamelCase   :Union[str, Any] ,      lowerCamelCase   :Tuple ,      lowerCamelCase   :Optional[Any]      )     ->			Optional[int]:
       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] ,      lowerCamelCase      )

         self.top_to_bottom(lowerCamelCase ,      lowerCamelCase ,      lowerCamelCase ,      lowerCamelCase      )
      def 	UpperCAmelCase_						(			self   :Union[str, Any] ,      lowerCamelCase   :Union[str, Any] ,      lowerCamelCase   :List[str] ,      lowerCamelCase   :List[Any] ,      lowerCamelCase   :Tuple      )     ->			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] ,      lowerCamelCase      )
        else:
         UpperCAmelCase__							 =						val
         UpperCAmelCase__							 =						temp
         self.set_position(lowerCamelCase ,      lowerCamelCase      )
         break
        UpperCAmelCase__							 =						parent
       else:
        UpperCAmelCase__							 =						val
        UpperCAmelCase__							 =						temp
        self.set_position(lowerCamelCase ,      0      )
      def 	UpperCAmelCase_						(			self   :List[str] ,      lowerCamelCase   :Dict ,      lowerCamelCase   :Optional[int]      )     ->			Optional[int]:
       UpperCAmelCase__							 =						len(lowerCamelCase      ) // 2 - 1
       for i in range(lowerCamelCase ,      -1 ,      -1      ):
        self.top_to_bottom(lowerCamelCase ,      lowerCamelCase ,      len(lowerCamelCase      ) ,      lowerCamelCase      )







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



def 						lowerCAmelCase		(		_lowerCAmelCase							:   Optional[Any]	):




 """simple docstring"""







 UpperCAmelCase__							 =						Heap()

 UpperCAmelCase__							 =						[0] * len(_lowerCAmelCase	)
 UpperCAmelCase__							 =						[-1] * len(_lowerCAmelCase	)  # 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(_lowerCAmelCase	)	):
  distance_tv.append(sys.maxsize	)
  positions.append(_lowerCAmelCase	)
  heap.node_position.append(_lowerCAmelCase	)

 UpperCAmelCase__							 =						[]
 UpperCAmelCase__							 =						1
 UpperCAmelCase__							 =						sys.maxsize
 for neighbor, distance in adjacency_list[0]:
  UpperCAmelCase__							 =						0
  UpperCAmelCase__							 =						distance
 heap.heapify(_lowerCAmelCase						,							_lowerCAmelCase	)

 for _ in range(1						,							len(_lowerCAmelCase	)	):
  UpperCAmelCase__							 =						heap.delete_minimum(_lowerCAmelCase						,							_lowerCAmelCase	)
  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(_lowerCAmelCase	)]
    ):
     UpperCAmelCase__							 =						distance
     heap.bottom_to_top(
         _lowerCAmelCase						,							heap.get_position(_lowerCAmelCase	)						,							_lowerCAmelCase						,							_lowerCAmelCase	)
     UpperCAmelCase__							 =						vertex
 return tree_edges


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











# This script creates a super tiny model that is useful inside tests, when we just want to test that
# the machinery works, without needing to the check the quality of the outcomes.
#
# This version creates a tiny model through reduction of a normal pre-trained model, but keeping the
# full vocab, merges file, and thus also resulting in a larger model due to a large vocab size.
# This gives ~3MB in total for all files.
#
# If you want a 50 times smaller than this see `fsmt-make-super-tiny-model.py`, which is slightly more complicated
#
#
# It will be used then as "stas/tiny-wmt19-en-de"

# Build
from transformers import FSMTTokenizer, FSMTConfig, FSMTForConditionalGeneration

_lowerCAmelCase						:   int		=   "facebook/wmt19-en-de"
_lowerCAmelCase						:   int		=   FSMTTokenizer.from_pretrained(mname)
# get the correct vocab sizes, etc. from the master model
_lowerCAmelCase						:   Dict		=   FSMTConfig.from_pretrained(mname)
config.update(
    dict(
        d_model=4,
        encoder_layers=1,
        decoder_layers=1,
        encoder_ffn_dim=4,
        decoder_ffn_dim=4,
        encoder_attention_heads=1,
        decoder_attention_heads=1,
    )
)

_lowerCAmelCase						:   List[Any]		=   FSMTForConditionalGeneration(config)
print(F'''num of params {tiny_model.num_parameters()}''')

# Test
_lowerCAmelCase						:   Optional[Any]		=   tokenizer(["Making tiny model"], return_tensors="pt")
_lowerCAmelCase						:   Optional[Any]		=   tiny_model(**batch)

print("test output:", len(outputs.logits[0]))

# Save
_lowerCAmelCase						:   Optional[Any]		=   "tiny-wmt19-en-de"
tiny_model.half()  # makes it smaller
tiny_model.save_pretrained(mname_tiny)
tokenizer.save_pretrained(mname_tiny)

print(F'''Generated {mname_tiny}''')

# Upload
# transformers-cli upload tiny-wmt19-en-de





