





import json
import os
import unittest

from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer
from transformers.testing_utils import slow

from ...test_tokenization_common import TokenizerTesterMixin



class    _a     (				a__					,							unittest.TestCase							):






       """simple docstring"""

       snake_case_							 =						XLMTokenizer
       snake_case_							 =						False

       def      A_  (      self				:     str    )	->Union[str, Any]:
             super().setUp()

             # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
             SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					[
                 '''l''',
                 '''o''',
                 '''w''',
                 '''e''',
                 '''r''',
                 '''s''',
                 '''t''',
                 '''i''',
                 '''d''',
                 '''n''',
                 '''w</w>''',
                 '''r</w>''',
                 '''t</w>''',
                 '''lo''',
                 '''low''',
                 '''er</w>''',
                 '''low</w>''',
                 '''lowest</w>''',
                 '''newer</w>''',
                 '''wider</w>''',
                 '''<unk>''',
             ]
             SCREAMING_SNAKE_CASE__     :				Any   =					dict(zip(lowercase__							,	range(len(lowercase__    )    )    )    )
             SCREAMING_SNAKE_CASE__     :				List[Any]   =					['''l o 123''', '''lo w 1456''', '''e r</w> 1789''', '''''']

             SCREAMING_SNAKE_CASE__     :				Any   =					os.path.join(self.tmpdirname							,	VOCAB_FILES_NAMES["vocab_file"]    )
             SCREAMING_SNAKE_CASE__     :				str   =					os.path.join(self.tmpdirname							,	VOCAB_FILES_NAMES["merges_file"]    )
             with open(self.vocab_file							,	"w"    ) as fp:
                   fp.write(json.dumps(lowercase__    )    )
             with open(self.merges_file							,	"w"    ) as fp:
                   fp.write("\n".join(lowercase__    )    )

       def      A_  (      self				:     Any							,	a				:     Optional[Any]    )	->Optional[Any]:
             SCREAMING_SNAKE_CASE__     :				List[Any]   =					'''lower newer'''
             SCREAMING_SNAKE_CASE__     :				Dict   =					'''lower newer'''
             return input_text, output_text

       def      A_  (      self				:     Any    )	->Tuple:
             SCREAMING_SNAKE_CASE__     :				Tuple   =					XLMTokenizer(self.vocab_file							,	self.merges_file    )

             SCREAMING_SNAKE_CASE__     :				Optional[int]   =					'''lower'''
             SCREAMING_SNAKE_CASE__     :				str   =					['''low''', '''er</w>''']
             SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					tokenizer.tokenize(lowercase__    )
             self.assertListEqual(lowercase__							,	lowercase__    )

             SCREAMING_SNAKE_CASE__     :				Tuple   =					tokens + ['''<unk>''']
             SCREAMING_SNAKE_CASE__     :				Dict   =					[14, 15, 20]
             self.assertListEqual(tokenizer.convert_tokens_to_ids(lowercase__    )							,	lowercase__    )






       @slow
       def      A_  (      self				:     Any    )	->Union[str, Any]:
             SCREAMING_SNAKE_CASE__     :				List[Any]   =					XLMTokenizer.from_pretrained("xlm-mlm-en-2048"    )

             SCREAMING_SNAKE_CASE__     :				str   =					tokenizer.encode("sequence builders"							,	add_special_tokens=lowercase__    )
             SCREAMING_SNAKE_CASE__     :				Tuple   =					tokenizer.encode("multi-sequence build"							,	add_special_tokens=lowercase__    )

             SCREAMING_SNAKE_CASE__     :				Tuple   =					tokenizer.build_inputs_with_special_tokens(lowercase__    )
             SCREAMING_SNAKE_CASE__     :				List[str]   =					tokenizer.build_inputs_with_special_tokens(lowercase__							,	lowercase__    )

             assert encoded_sentence == [0] + text + [1]
             assert encoded_pair == [0] + text + [1] + text_a + [1]






import sys
from collections import defaultdict



class    _a     :






							"""simple docstring"""

							def __init__(      self				:     Any    )	->Dict:
													SCREAMING_SNAKE_CASE__     :				Tuple   =					[]

							def      A_  (      self				:     int							,	a				:     List[str]    )	->Dict:
													return self.node_position[vertex]

							def      A_  (      self				:     Optional[Any]							,	a				:     Any							,	a				:     List[str]    )	->Optional[Any]:
													SCREAMING_SNAKE_CASE__     :				str   =					pos

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

																									SCREAMING_SNAKE_CASE__     :				Optional[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      A_  (      self				:     Union[str, Any]							,	a				:     Tuple							,	a				:     Tuple							,	a				:     Union[str, Any]							,	a				:     List[Any]    )	->Optional[int]:
													SCREAMING_SNAKE_CASE__     :				List[Any]   =					position[index]

													while index != 0:
																			SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					int((index - 2) / 2    ) if index % 2 == 0 else int((index - 1) / 2    )

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

							def      A_  (      self				:     Union[str, Any]							,	a				:     int							,	a				:     List[str]    )	->Union[str, Any]:
													SCREAMING_SNAKE_CASE__     :				List[str]   =					len(a    ) // 2 - 1
													for i in range(a							,	-1							,	-1    ):
																			self.top_to_bottom(a							,	a							,	len(a    )							,	a    )






							def      A_  (      self				:     Dict							,	a				:     List[Any]							,	a				:     Dict    )	->Optional[int]:
													SCREAMING_SNAKE_CASE__     :				Any   =					positions[0]
													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					sys.maxsize
													self.top_to_bottom(a							,	0							,	len(a    )							,	a    )
													return temp







def       UpperCAmelCase							(     _lowerCamelCase      :  str     ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__     :				Optional[int]   =					Heap()

						SCREAMING_SNAKE_CASE__     :				Any   =					[0] * len(_lowerCamelCase     )
						SCREAMING_SNAKE_CASE__     :				Any   =					[-1] * len(_lowerCamelCase     )  # Neighboring Tree Vertex of selected vertex
						# Minimum Distance of explored vertex with neighboring vertex of partial tree
						# formed in graph
						SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					[]  # Heap of Distance of vertices from their neighboring vertex
						SCREAMING_SNAKE_CASE__     :				str   =					[]

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

						SCREAMING_SNAKE_CASE__     :				List[Any]   =					[]
						SCREAMING_SNAKE_CASE__     :				int   =					1
						SCREAMING_SNAKE_CASE__     :				int   =					sys.maxsize
						for neighbor, distance in adjacency_list[0]:
												SCREAMING_SNAKE_CASE__     :				int   =					0
												SCREAMING_SNAKE_CASE__     :				List[str]   =					distance
						heap.heapify(_lowerCamelCase			,   _lowerCamelCase     )

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


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