'''simple docstring'''




import sys
from collections import defaultdict


class       UpperCAmelCase__  :






   """simple docstring"""
   def __init__(self				)    ->     List[str]:
        lowercase_					:       str     				=					[]
   def 		_lowerCamelCase (self       ,				_a				)    ->     str:
        return self.node_position[vertex]
   def 		_lowerCamelCase (self       ,				_a       ,				_a				)    ->     Union[str, Any]:
        lowercase_					:       Optional[Any]     				=					pos
   def 		_lowerCamelCase (self       ,				_a       ,				_a       ,				_a       ,				_a				)    ->     Dict:
        if start > size // 2 - 1:
             return
        else:
             if 2 * start + 2 >= size:
                  lowercase_					:       Optional[Any]     				=					2 * start + 1
             else:
                  if heap[2 * start + 1] < heap[2 * start + 2]:
                       lowercase_					:       Dict     				=					2 * start + 1
                  else:
                       lowercase_					:       Union[str, Any]     				=					2 * start + 2
             if heap[smallest_child] < heap[start]:
                  lowercase_				,lowercase_					:       int     				=					heap[smallest_child], positions[smallest_child]
                  lowercase_				,lowercase_					:       List[str]     				=					(
                      heap[start],
                      positions[start],
                  )
                  lowercase_				,lowercase_					:       Optional[int]     				=					temp, tempa

                  lowercase_					:       Optional[int]     				=					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 		_lowerCamelCase (self       ,				_a       ,				_a       ,				_a       ,				_a				)    ->     int:
        lowercase_					:       Optional[int]     				=					position[index]

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

             if val < heap[parent]:
                  lowercase_					:       Union[str, Any]     				=					heap[parent]
                  lowercase_					:       Dict     				=					position[parent]
                  self.set_position(position[parent]       ,				_a				)
             else:
                  lowercase_					:       Union[str, Any]     				=					val
                  lowercase_					:       List[Any]     				=					temp
                  self.set_position(_a       ,				_a				)
                  break
             lowercase_					:       str     				=					parent
        else:
             lowercase_					:       Optional[Any]     				=					val
             lowercase_					:       Tuple     				=					temp
             self.set_position(_a       ,				0				)
   def 		_lowerCamelCase (self       ,				_a       ,				_a				)    ->     Optional[int]:
        lowercase_					:       Any     				=					len(_a				) // 2 - 1
        for i in range(_a       ,				-1       ,				-1				):
             self.top_to_bottom(_a       ,				_a       ,				len(_a				)       ,				_a				)





   def 		_lowerCamelCase (self       ,				_a       ,				_a				)    ->     Tuple:
        lowercase_					:       int     				=					positions[0]
        lowercase_					:       Dict     				=					sys.maxsize
        self.top_to_bottom(_a       ,				0       ,				len(_a				)       ,				_a				)
        return temp



def _UpperCamelCase   (       SCREAMING_SNAKE_CASE_							):
     lowercase_					:       Optional[int]     				=					Heap()

     lowercase_					:       str     				=					[0] * len(SCREAMING_SNAKE_CASE_							)
     lowercase_					:       Union[str, Any]     				=					[-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
     lowercase_					:       Any     				=					[]  # Heap of Distance of vertices from their neighboring vertex
     lowercase_					:       str     				=					[]

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

     lowercase_					:       Any     				=					[]
     lowercase_					:       int     				=					1
     lowercase_					:       Dict     				=					sys.maxsize
     for neighbor, distance in adjacency_list[0]:
          lowercase_					:       str     				=					0
          lowercase_					:       Union[str, Any]     				=					distance
     heap.heapify(SCREAMING_SNAKE_CASE_  ,       SCREAMING_SNAKE_CASE_							)

     for _ in range(1  ,       len(SCREAMING_SNAKE_CASE_							)							):
          lowercase_					:       Any     				=					heap.delete_minimum(SCREAMING_SNAKE_CASE_  ,       SCREAMING_SNAKE_CASE_							)
          if visited[vertex] == 0:
               tree_edges.append((nbr_tv[vertex], vertex)							)
               lowercase_					:       Union[str, Any]     				=					1
               for neighbor, distance in adjacency_list[vertex]:
                    if (
                        visited[neighbor] == 0
                        and distance < distance_tv[heap.get_position(SCREAMING_SNAKE_CASE_							)]
                    ):
                         lowercase_					:       List[str]     				=					distance
                         heap.bottom_to_top(
                             SCREAMING_SNAKE_CASE_  ,       heap.get_position(SCREAMING_SNAKE_CASE_							)  ,       SCREAMING_SNAKE_CASE_  ,       SCREAMING_SNAKE_CASE_							)
                         lowercase_					:       int     				=					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))





'''simple docstring'''




import json
import os
import shutil
import tempfile
import unittest

import numpy as np
import pytest

from transformers import BertTokenizer, BertTokenizerFast
from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES
from transformers.testing_utils import require_vision
from transformers.utils import IMAGE_PROCESSOR_NAME, is_vision_available


if is_vision_available():
 from PIL import Image

 from transformers import AlignProcessor, EfficientNetImageProcessor


@require_vision
class       UpperCAmelCase__  (       unittest.TestCase			):






   """simple docstring"""
   def 		_lowerCamelCase (self				)    ->     List[Any]:
        lowercase_					:       Any     				=					tempfile.mkdtemp()

        lowercase_					:       int     				=					[
            '[UNK]',
            '[CLS]',
            '[SEP]',
            '[PAD]',
            '[MASK]',
            'want',
            '##want',
            '##ed',
            'wa',
            'un',
            'runn',
            '##ing',
            ',',
            'low',
            'lowest',
        ]
        lowercase_					:       Union[str, Any]     				=					os.path.join(self.tmpdirname       ,				VOCAB_FILES_NAMES['vocab_file']				)
        with open(self.vocab_file       ,				'w'       ,				encoding='utf-8'				) as vocab_writer:
             vocab_writer.write(''.join([x + '\n' for x in vocab_tokens]				)				)

        lowercase_					:       Union[str, Any]     				=					{
            'do_resize': True,
            'size': 20,
            'do_center_crop': True,
            'crop_size': 18,
            'do_normalize': True,
            'image_mean': [0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73],
            'image_std': [0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11],
        }
        lowercase_					:       List[str]     				=					os.path.join(self.tmpdirname       ,				_a				)
        with open(self.image_processor_file       ,				'w'       ,				encoding='utf-8'				) as fp:
             json.dump(_a       ,				_a				)
   def 		_lowerCamelCase (self       ,				**_a				)    ->     Tuple:
        return BertTokenizer.from_pretrained(self.tmpdirname       ,				**_a				)
   def 		_lowerCamelCase (self       ,				**_a				)    ->     Tuple:
        return BertTokenizerFast.from_pretrained(self.tmpdirname       ,				**_a				)
   def 		_lowerCamelCase (self       ,				**_a				)    ->     int:
        return EfficientNetImageProcessor.from_pretrained(self.tmpdirname       ,				**_a				)
   def 		_lowerCamelCase (self				)    ->     Dict:
        shutil.rmtree(self.tmpdirname				)
   def 		_lowerCamelCase (self				)    ->     str:
        lowercase_					:       List[str]     				=					[np.random.randint(255       ,				size=(3, 30, 400)       ,				dtype=np.uinta				)]
        lowercase_					:       Optional[Any]     				=					[Image.fromarray(np.moveaxis(_a       ,				0       ,				-1				)				) for x in image_inputs]
        return image_inputs
   def 		_lowerCamelCase (self				)    ->     Optional[Any]:
        lowercase_					:       str     				=					self.get_tokenizer()
        lowercase_					:       Tuple     				=					self.get_rust_tokenizer()
        lowercase_					:       int     				=					self.get_image_processor()

        lowercase_					:       int     				=					AlignProcessor(tokenizer=_a       ,				image_processor=_a				)
        processor_slow.save_pretrained(self.tmpdirname				)
        lowercase_					:       List[str]     				=					AlignProcessor.from_pretrained(self.tmpdirname       ,				use_fast=_a				)

        lowercase_					:       Optional[Any]     				=					AlignProcessor(tokenizer=_a       ,				image_processor=_a				)
        processor_fast.save_pretrained(self.tmpdirname				)
        lowercase_					:       Any     				=					AlignProcessor.from_pretrained(self.tmpdirname				)

        self.assertEqual(processor_slow.tokenizer.get_vocab()       ,				tokenizer_slow.get_vocab()				)
        self.assertEqual(processor_fast.tokenizer.get_vocab()       ,				tokenizer_fast.get_vocab()				)
        self.assertEqual(tokenizer_slow.get_vocab()       ,				tokenizer_fast.get_vocab()				)
        self.assertIsInstance(processor_slow.tokenizer       ,				_a				)
        self.assertIsInstance(processor_fast.tokenizer       ,				_a				)

        self.assertEqual(processor_slow.image_processor.to_json_string()       ,				image_processor.to_json_string()				)
        self.assertEqual(processor_fast.image_processor.to_json_string()       ,				image_processor.to_json_string()				)
        self.assertIsInstance(processor_slow.image_processor       ,				_a				)
        self.assertIsInstance(processor_fast.image_processor       ,				_a				)
   def 		_lowerCamelCase (self				)    ->     Tuple:
        lowercase_					:       str     				=					AlignProcessor(tokenizer=self.get_tokenizer()       ,				image_processor=self.get_image_processor()				)
        processor.save_pretrained(self.tmpdirname				)

        lowercase_					:       Tuple     				=					self.get_tokenizer(bos_token='(BOS)'       ,				eos_token='(EOS)'				)
        lowercase_					:       str     				=					self.get_image_processor(do_normalize=_a       ,				padding_value=1.0				)

        lowercase_					:       Optional[Any]     				=					AlignProcessor.from_pretrained(
            self.tmpdirname       ,				bos_token='(BOS)'       ,				eos_token='(EOS)'       ,				do_normalize=_a       ,				padding_value=1.0				)

        self.assertEqual(processor.tokenizer.get_vocab()       ,				tokenizer_add_kwargs.get_vocab()				)
        self.assertIsInstance(processor.tokenizer       ,				_a				)

        self.assertEqual(processor.image_processor.to_json_string()       ,				image_processor_add_kwargs.to_json_string()				)
        self.assertIsInstance(processor.image_processor       ,				_a				)
   def 		_lowerCamelCase (self				)    ->     List[str]:
        lowercase_					:       Union[str, Any]     				=					self.get_image_processor()
        lowercase_					:       Union[str, Any]     				=					self.get_tokenizer()

        lowercase_					:       Optional[int]     				=					AlignProcessor(tokenizer=_a       ,				image_processor=_a				)

        lowercase_					:       Union[str, Any]     				=					self.prepare_image_inputs()

        lowercase_					:       Union[str, Any]     				=					image_processor(_a       ,				return_tensors='np'				)
        lowercase_					:       Union[str, Any]     				=					processor(images=_a       ,				return_tensors='np'				)

        for key in input_image_proc.keys():
             self.assertAlmostEqual(input_image_proc[key].sum()       ,				input_processor[key].sum()       ,				delta=1e-2				)
   def 		_lowerCamelCase (self				)    ->     Dict:
        lowercase_					:       List[Any]     				=					self.get_image_processor()
        lowercase_					:       int     				=					self.get_tokenizer()

        lowercase_					:       Any     				=					AlignProcessor(tokenizer=_a       ,				image_processor=_a				)

        lowercase_					:       Tuple     				=					'lower newer'

        lowercase_					:       Optional[Any]     				=					processor(text=_a				)

        lowercase_					:       List[Any]     				=					tokenizer(_a       ,				padding='max_length'       ,				max_length=64				)

        for key in encoded_tok.keys():
             self.assertListEqual(encoded_tok[key]       ,				encoded_processor[key]				)
   def 		_lowerCamelCase (self				)    ->     List[Any]:
        lowercase_					:       Any     				=					self.get_image_processor()
        lowercase_					:       List[Any]     				=					self.get_tokenizer()

        lowercase_					:       List[str]     				=					AlignProcessor(tokenizer=_a       ,				image_processor=_a				)

        lowercase_					:       Optional[Any]     				=					'lower newer'
        lowercase_					:       List[Any]     				=					self.prepare_image_inputs()

        lowercase_					:       List[str]     				=					processor(text=_a       ,				images=_a				)

        self.assertListEqual(list(inputs.keys()				)       ,				['input_ids', 'token_type_ids', 'attention_mask', 'pixel_values']				)

        # test if it raises when no input is passed
        with pytest.raises(_a				):
             processor()
   def 		_lowerCamelCase (self				)    ->     Tuple:
        lowercase_					:       Dict     				=					self.get_image_processor()
        lowercase_					:       Optional[Any]     				=					self.get_tokenizer()

        lowercase_					:       Optional[Any]     				=					AlignProcessor(tokenizer=_a       ,				image_processor=_a				)

        lowercase_					:       Union[str, Any]     				=					[[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

        lowercase_					:       str     				=					processor.batch_decode(_a				)
        lowercase_					:       Dict     				=					tokenizer.batch_decode(_a				)

        self.assertListEqual(_a       ,				_a				)





   def 		_lowerCamelCase (self				)    ->     List[str]:
        lowercase_					:       str     				=					self.get_image_processor()
        lowercase_					:       str     				=					self.get_tokenizer()

        lowercase_					:       str     				=					AlignProcessor(tokenizer=_a       ,				image_processor=_a				)

        lowercase_					:       Optional[int]     				=					'lower newer'
        lowercase_					:       Union[str, Any]     				=					self.prepare_image_inputs()

        lowercase_					:       Union[str, Any]     				=					processor(text=_a       ,				images=_a				)

        self.assertListEqual(list(inputs.keys()				)       ,				processor.model_input_names				)




