


import sys
from collections import defaultdict

class 						A__							:




						def __init__(       self					:      List[Any]  )							->     Tuple:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[]




						def 							__UpperCamelCase				(       self					:      Optional[Any]				,    _a					:      str  )							->     Optional[Any]:


										"""simple docstring"""





										return self.node_position[vertex]




						def 							__UpperCamelCase				(       self					:      Any				,    _a					:      Union[str, Any]				,    _a					:      List[str]  )							->     Union[str, Any]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =pos




						def 							__UpperCamelCase				(       self					:      Any				,    _a					:      List[Any]				,    _a					:      Tuple				,    _a					:      Tuple				,    _a					:      Tuple  )							->     Optional[Any]:


										"""simple docstring"""





										if start > size // 2 - 1:
														return
										else:
														if 2 * start + 2 >= size:
																		_SCREAMING_SNAKE_CASE			  =2 * start + 1
														else:
																		if heap[2 * start + 1] < heap[2 * start + 2]:
																						_SCREAMING_SNAKE_CASE			  =2 * start + 1
																		else:
																						_SCREAMING_SNAKE_CASE			  =2 * start + 2
														if heap[smallest_child] < heap[start]:
																		_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE			  =heap[smallest_child], positions[smallest_child]
																		_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE			  =(
																		    heap[start],
																		    positions[start],
																		)
																		_SCREAMING_SNAKE_CASE  ,				_SCREAMING_SNAKE_CASE			  =temp, tempa

																		_SCREAMING_SNAKE_CASE			  =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					:      Dict				,    _a					:      Optional[int]				,    _a					:      Any				,    _a					:      int				,    _a					:      int  )							->     List[str]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =position[index]

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

														if val < heap[parent]:
																		_SCREAMING_SNAKE_CASE			  =heap[parent]
																		_SCREAMING_SNAKE_CASE			  =position[parent]
																		self.set_position(position[parent]				,    _a  )
														else:
																		_SCREAMING_SNAKE_CASE			  =val
																		_SCREAMING_SNAKE_CASE			  =temp
																		self.set_position(_a				,    _a  )
																		break
														_SCREAMING_SNAKE_CASE			  =parent
										else:
														_SCREAMING_SNAKE_CASE			  =val
														_SCREAMING_SNAKE_CASE			  =temp
														self.set_position(_a				,    0  )




						def 							__UpperCamelCase				(       self					:      Optional[Any]				,    _a					:      str				,    _a					:      List[str]  )							->     Tuple:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =len(_a  ) // 2 - 1
										for i in range(_a				,    -1				,    -1  ):
														self.top_to_bottom(_a				,    _a				,    len(_a  )				,    _a  )




						def 							__UpperCamelCase				(       self					:      List[str]				,    _a					:      List[Any]				,    _a					:      List[str]  )							->     Optional[int]:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =positions[0]
										_SCREAMING_SNAKE_CASE			  =sys.maxsize
										self.top_to_bottom(_a				,    0				,    len(_a  )				,    _a  )
										return temp







def 						lowerCamelCase(   a__):
				_SCREAMING_SNAKE_CASE			  =Heap()

				_SCREAMING_SNAKE_CASE			  =[0] * len(a__)
				_SCREAMING_SNAKE_CASE			  =[-1] * len(a__)  # Neighboring Tree Vertex of selected vertex
				# Minimum Distance of explored vertex with neighboring vertex of partial tree
				# formed in graph
				_SCREAMING_SNAKE_CASE			  =[]  # Heap of Distance of vertices from their neighboring vertex
				_SCREAMING_SNAKE_CASE			  =[]

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

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

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


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



import json
import os
import unittest

from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast
from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES
from transformers.testing_utils import require_tokenizers, require_torch
from transformers.utils import cached_property

from ...test_tokenization_common import TokenizerTesterMixin

@require_tokenizers
class 						A__							(		UpperCamelCase__   ,     unittest.TestCase  ):
						UpperCAmelCase             =						LEDTokenizer
						UpperCAmelCase             =						LEDTokenizerFast
						UpperCAmelCase             =						True




						def 							__UpperCamelCase				(       self					:      Dict  )							->     Optional[int]:


										"""simple docstring"""





										super().setUp()
										_SCREAMING_SNAKE_CASE			  =[
										    '''l''',
										    '''o''',
										    '''w''',
										    '''e''',
										    '''r''',
										    '''s''',
										    '''t''',
										    '''i''',
										    '''d''',
										    '''n''',
										    '''\u0120''',
										    '''\u0120l''',
										    '''\u0120n''',
										    '''\u0120lo''',
										    '''\u0120low''',
										    '''er''',
										    '''\u0120lowest''',
										    '''\u0120newer''',
										    '''\u0120wider''',
										    '''<unk>''',
										]
										_SCREAMING_SNAKE_CASE			  =dict(zip(_a				,    range(len(_a  )  )  )  )
										_SCREAMING_SNAKE_CASE			  =['''#version: 0.2''', '''\u0120 l''', '''\u0120l o''', '''\u0120lo w''', '''e r''', '''''']
										_SCREAMING_SNAKE_CASE			  ={'''unk_token''': '''<unk>'''}

										_SCREAMING_SNAKE_CASE			  =os.path.join(self.tmpdirname				,    VOCAB_FILES_NAMES['''vocab_file''']  )
										_SCREAMING_SNAKE_CASE			  =os.path.join(self.tmpdirname				,    VOCAB_FILES_NAMES['''merges_file''']  )
										with open(self.vocab_file				,    '''w'''				,    encoding='''utf-8'''  ) as fp:
														fp.write(json.dumps(_a  ) + '''\n'''  )
										with open(self.merges_file				,    '''w'''				,    encoding='''utf-8'''  ) as fp:
														fp.write('''\n'''.join(_a  )  )




						def 							__UpperCamelCase				(       self					:      str				,    **_a					:      int  )							->     Optional[Any]:


										"""simple docstring"""





										kwargs.update(self.special_tokens_map  )
										return self.tokenizer_class.from_pretrained(self.tmpdirname				,    **_a  )




						def 							__UpperCamelCase				(       self					:      List[str]				,    **_a					:      List[Any]  )							->     str:


										"""simple docstring"""





										kwargs.update(self.special_tokens_map  )
										return self.rust_tokenizer_class.from_pretrained(self.tmpdirname				,    **_a  )




						def 							__UpperCamelCase				(       self					:      Dict				,    _a					:      Any  )							->     Dict:


										"""simple docstring"""





										return "lower newer", "lower newer"




						@cached_property
						def 							__UpperCamelCase				(       self					:      Optional[Any]  )							->     Dict:


										"""simple docstring"""





										return LEDTokenizer.from_pretrained('''allenai/led-base-16384'''  )




						@cached_property
						def 							__UpperCamelCase				(       self					:      List[Any]  )							->     Any:


										"""simple docstring"""





										return LEDTokenizerFast.from_pretrained('''allenai/led-base-16384'''  )




						@require_torch
						def 							__UpperCamelCase				(       self					:      str  )							->     Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
										_SCREAMING_SNAKE_CASE			  =[0, 250, 251, 1_7818, 13, 3_9186, 1938, 4, 2]

										for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
														_SCREAMING_SNAKE_CASE			  =tokenizer(_a				,    max_length=len(_a  )				,    padding=_a				,    return_tensors='''pt'''  )
														self.assertIsInstance(_a				,    _a  )

														self.assertEqual((2, 9)				,    batch.input_ids.shape  )
														self.assertEqual((2, 9)				,    batch.attention_mask.shape  )
														_SCREAMING_SNAKE_CASE			  =batch.input_ids.tolist()[0]
														self.assertListEqual(_a				,    _a  )




						@require_torch
						def 							__UpperCamelCase				(       self					:      Dict  )							->     Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =['''A long paragraph for summarization.''', '''Another paragraph for summarization.''']
										for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
														_SCREAMING_SNAKE_CASE			  =tokenizer(_a				,    padding=_a				,    return_tensors='''pt'''  )
														self.assertIn('''input_ids'''				,    _a  )
														self.assertIn('''attention_mask'''				,    _a  )
														self.assertNotIn('''labels'''				,    _a  )
														self.assertNotIn('''decoder_attention_mask'''				,    _a  )




						@require_torch
						def 							__UpperCamelCase				(       self					:      Dict  )							->     str:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[
										    '''Summary of the text.''',
										    '''Another summary.''',
										]
										for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
														_SCREAMING_SNAKE_CASE			  =tokenizer(text_target=_a				,    max_length=32				,    padding='''max_length'''				,    return_tensors='''pt'''  )
														self.assertEqual(32				,    targets['''input_ids'''].shape[1]  )




						@require_torch
						def 							__UpperCamelCase				(       self					:      Any  )							->     Union[str, Any]:


										"""simple docstring"""





										for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
														_SCREAMING_SNAKE_CASE			  =tokenizer(
														    ['''I am a small frog''' * 1024, '''I am a small frog''']				,    padding=_a				,    truncation=_a				,    return_tensors='''pt'''  )
														self.assertIsInstance(_a				,    _a  )
														self.assertEqual(batch.input_ids.shape				,    (2, 5122)  )




						@require_torch
						def 							__UpperCamelCase				(       self					:      int  )							->     Dict:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =['''A long paragraph for summarization.''']
										_SCREAMING_SNAKE_CASE			  =[
										    '''Summary of the text.''',
										]
										for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
														_SCREAMING_SNAKE_CASE			  =tokenizer(_a				,    return_tensors='''pt'''  )
														_SCREAMING_SNAKE_CASE			  =tokenizer(text_target=_a				,    return_tensors='''pt'''  )
														_SCREAMING_SNAKE_CASE			  =inputs['''input_ids''']
														_SCREAMING_SNAKE_CASE			  =targets['''input_ids''']
														self.assertTrue((input_ids[:, 0] == tokenizer.bos_token_id).all().item()  )
														self.assertTrue((labels[:, 0] == tokenizer.bos_token_id).all().item()  )
														self.assertTrue((input_ids[:, -1] == tokenizer.eos_token_id).all().item()  )
														self.assertTrue((labels[:, -1] == tokenizer.eos_token_id).all().item()  )




						@require_torch
						def 							__UpperCamelCase				(       self					:      Optional[Any]  )							->     str:


										"""simple docstring"""





										for tokenizer in [self.default_tokenizer, self.default_tokenizer_fast]:
														_SCREAMING_SNAKE_CASE			  =['''Summary of the text.''', '''Another summary.''']
														_SCREAMING_SNAKE_CASE			  =[[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, -1, -1]]

														_SCREAMING_SNAKE_CASE			  =tokenizer(_a				,    padding=_a  )
														_SCREAMING_SNAKE_CASE			  =[[0] * len(_a  ) for x in encoded_output['''input_ids''']]
														_SCREAMING_SNAKE_CASE			  =tokenizer.pad(_a  )
														self.assertSequenceEqual(outputs['''global_attention_mask''']				,    _a  )




						def 							__UpperCamelCase				(       self					:      int  )							->     List[str]:


										"""simple docstring"""





										pass




						def 							__UpperCamelCase				(       self					:      Union[str, Any]  )							->     str:


										"""simple docstring"""





										for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
														with self.subTest(f"{tokenizer.__class__.__name__} ({pretrained_name})"  ):
																		_SCREAMING_SNAKE_CASE			  =self.rust_tokenizer_class.from_pretrained(_a				,    **_a  )
																		_SCREAMING_SNAKE_CASE			  =self.tokenizer_class.from_pretrained(_a				,    **_a  )
																		_SCREAMING_SNAKE_CASE			  ='''A, <mask> AllenNLP sentence.'''
																		_SCREAMING_SNAKE_CASE			  =tokenizer_r.encode_plus(_a				,    add_special_tokens=_a				,    return_token_type_ids=_a  )
																		_SCREAMING_SNAKE_CASE			  =tokenizer_p.encode_plus(_a				,    add_special_tokens=_a				,    return_token_type_ids=_a  )
																		self.assertEqual(sum(tokens_r['''token_type_ids''']  )				,    sum(tokens_p['''token_type_ids''']  )  )
																		self.assertEqual(
																		    sum(tokens_r['''attention_mask''']  ) / len(tokens_r['''attention_mask''']  )				,    sum(tokens_p['''attention_mask''']  ) / len(tokens_p['''attention_mask''']  )				,    )

																		_SCREAMING_SNAKE_CASE			  =tokenizer_r.convert_ids_to_tokens(tokens_r['''input_ids''']  )
																		_SCREAMING_SNAKE_CASE			  =tokenizer_p.convert_ids_to_tokens(tokens_p['''input_ids''']  )
																		self.assertSequenceEqual(tokens_p['''input_ids''']				,    [0, 250, 6, 5_0264, 3823, 487, 2_1992, 3645, 4, 2]  )
																		self.assertSequenceEqual(tokens_r['''input_ids''']				,    [0, 250, 6, 5_0264, 3823, 487, 2_1992, 3645, 4, 2]  )

																		self.assertSequenceEqual(
																		    _a				,    ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>''']  )
																		self.assertSequenceEqual(
																		    _a				,    ['''<s>''', '''A''', ''',''', '''<mask>''', '''ĠAllen''', '''N''', '''LP''', '''Ġsentence''', '''.''', '''</s>''']  )