


import json
import re
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

import numpy as np

from ...utils import is_tf_available, is_torch_available, logging


if TYPE_CHECKING:
		if is_torch_available():
				import torch
		if is_tf_available():
				import tensorflow as tf

from tokenizers import pre_tokenizers

from ...tokenization_utils_base import BatchEncoding
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from .tokenization_codegen import CodeGenTokenizer


snake_case__    =						logging.get_logger(__name__)

snake_case__    =						{'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.txt''', '''tokenizer_file''': '''tokenizer.json'''}

snake_case__    =						{
    '''vocab_file''': {
        '''Salesforce/codegen-350M-mono''': '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/vocab.json''',
    },
    '''merges_file''': {
        '''Salesforce/codegen-350M-mono''': '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/merges.txt''',
    },
    '''tokenizer_file''': {
        '''Salesforce/codegen-350M-mono''': (
            '''https://huggingface.co/Salesforce/codegen-350M-mono/resolve/main/tokenizer.json'''
        ),
    },
}

snake_case__    =						{
    '''Salesforce/codegen-350M-mono''': 2048,
}


class 					lowerCAmelCase_ (       _a):
						lowerCamelCase_         =     VOCAB_FILES_NAMES
						lowerCamelCase_         =     PRETRAINED_VOCAB_FILES_MAP
						lowerCamelCase_         =     PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						lowerCamelCase_         =     ['input_ids', 'attention_mask']
						lowerCamelCase_         =     CodeGenTokenizer




						def __init__(	self						:   Any   ,     __A						:   Union[str, Any]=None   ,     __A						:   Dict=None   ,     __A						:   int=None   ,     __A						:   Tuple="<|endoftext|>"   ,     __A						:   Union[str, Any]="<|endoftext|>"   ,     __A						:   List[str]="<|endoftext|>"   ,     __A						:   Optional[int]=False   ,     **__A						:   Optional[int]   ,     )      ->Union[str, Any]:






									"""simple docstring"""






									super().__init__(
									    __A   ,     __A   ,     tokenizer_file=__A   ,     unk_token=__A   ,     bos_token=__A   ,     eos_token=__A   ,     add_prefix_space=__A   ,     **__A   ,     )

									if kwargs.pop("add_bos_token"   ,     __A						):
												a__ :Dict						  =    kwargs.pop("name_or_path"   ,     ""						)
												raise ValueError(
												    "Currenty GPT2's fast tokenizer does NOT support adding a BOS token."
												    "Instead you should use GPT2's slow tokenizer class `CodeGenTokenizer` as follows: \n"
												    F'''`CodeGenTokenizer.from_pretrained(\'{model_id}\')`\nor\n'''
												    F'''`AutoTokenizer.from_pretrained(\'{model_id}\', use_fast=False)`\n'''
												    "This issue will be fixed soon, see: https://github.com/huggingface/tokenizers/pull/1005."
												    " so that the fast tokenizer works correctly."						)

									a__ :Optional[Any]						  =    json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__()						)
									if pre_tok_state.get("add_prefix_space"   ,     __A						) != add_prefix_space:
												a__ :Optional[Any]						  =    getattr(__A   ,     pre_tok_state.pop("type"						)						)
												a__ :str						  =    add_prefix_space
												a__ :Dict						  =    pre_tok_class(**__A						)

									a__ :str						  =    add_prefix_space




						def  _snake_case					(	self						:   Dict   ,     *__A						:   Optional[Any]   ,     **__A						:   List[Any]						)      ->BatchEncoding:






									"""simple docstring"""






									a__ :Union[str, Any]						  =    kwargs.get("is_split_into_words"   ,     __A						)
									assert self.add_prefix_space or not is_split_into_words, (
									    F'''You need to instantiate {self.__class__.__name__} with add_prefix_space=True '''
									    "to use it with pretokenized inputs."
									)

									return super()._batch_encode_plus(*__A   ,     **__A						)




						def  _snake_case					(	self						:   List[str]   ,     *__A						:   Union[str, Any]   ,     **__A						:   List[Any]						)      ->BatchEncoding:






									"""simple docstring"""






									a__ :Optional[int]						  =    kwargs.get("is_split_into_words"   ,     __A						)

									assert self.add_prefix_space or not is_split_into_words, (
									    F'''You need to instantiate {self.__class__.__name__} with add_prefix_space=True '''
									    "to use it with pretokenized inputs."
									)

									return super()._encode_plus(*__A   ,     **__A						)




						def  _snake_case					(	self						:   str   ,     __A						:   str   ,     __A						:   Optional[str] = None						)      ->Tuple[str]:






									"""simple docstring"""






									a__ :Optional[Any]						  =    self._tokenizer.model.save(__A   ,     name=__A						)
									return tuple(__A						)




						def  _snake_case					(	self						:   List[Any]   ,     __A						:   Union[int, List[int], "np.ndarray", "torch.Tensor", "tf.Tensor"]   ,     __A						:   bool = False   ,     __A						:   bool = None   ,     __A						:   Optional[List[str]] = None   ,     **__A						:   Any   ,     )      ->str:






									"""simple docstring"""






									a__ :List[Any]						  =    super().decode(
									    token_ids=__A   ,     skip_special_tokens=__A   ,     clean_up_tokenization_spaces=__A   ,     **__A   ,     )

									if truncate_before_pattern is not None and len(__A						) > 0:
												a__ :int						  =    self.truncate(__A   ,     __A						)

									return decoded_text






						def  _snake_case					(	self						:   Any   ,     __A						:   Union[str, Any]   ,     __A						:   Dict						)      ->str:






									"""simple docstring"""






									def find_re(__A						:   Any   ,     __A						:   Optional[int]   ,     __A						:   int						):
												a__ :Union[str, Any]						  =    pattern.search(__A   ,     __A						)
												return m.start() if m else -1

									a__ :Dict						  =    [re.compile(__A   ,     re.MULTILINE						) for pattern in truncate_before_pattern]

									a__ :Any						  =    list(re.finditer("^print"   ,     __A   ,     re.MULTILINE						)						)

									if len(__A						) > 1:
												a__ :str						  =    completion[: prints[1].start()]

									a__ :Union[str, Any]						  =    list(re.finditer("^def"   ,     __A   ,     re.MULTILINE						)						)

									if len(__A						) > 1:
												a__ :List[Any]						  =    completion[: defs[1].start()]

									a__ :str						  =    0

									a__ :Dict						  =    [
									    pos for pos in [find_re(__A   ,     __A   ,     __A						) for terminal in terminals] if pos != -1
									]

									if len(__A						) > 0:
												return completion[: min(__A						)]
									else:
												return completion






import sys
from collections import defaultdict


class 					lowerCAmelCase_ :




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






									"""simple docstring"""






									a__ :Optional[Any]						  =    []




						def  _snake_case					(	self						:   Optional[Any]   ,     __A						:   List[Any]						)      ->List[str]:






									"""simple docstring"""






									return self.node_position[vertex]




						def  _snake_case					(	self						:   Optional[Any]   ,     __A						:   str   ,     __A						:   Any						)      ->Dict:






									"""simple docstring"""






									a__ :Dict						  =    pos




						def  _snake_case					(	self						:   str   ,     __A						:   Union[str, Any]   ,     __A						:   Union[str, Any]   ,     __A						:   Optional[Any]   ,     __A						:   Optional[int]						)      ->List[Any]:






									"""simple docstring"""






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

															a__ :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  _snake_case					(	self						:   List[str]   ,     __A						:   Any   ,     __A						:   List[str]   ,     __A						:   Any   ,     __A						:   str						)      ->Optional[Any]:






									"""simple docstring"""






									a__ :Optional[Any]						  =    position[index]

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

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




						def  _snake_case					(	self						:   Tuple   ,     __A						:   int   ,     __A						:   int						)      ->Union[str, Any]:






									"""simple docstring"""






									a__ :Tuple						  =    len(__A						) // 2 - 1
									for i in range(__A   ,     -1   ,     -1						):
												self.top_to_bottom(__A   ,     __A   ,     len(__A						)   ,     __A						)






						def  _snake_case					(	self						:   List[Any]   ,     __A						:   List[Any]   ,     __A						:   int						)      ->Optional[Any]:






									"""simple docstring"""






									a__ :Any						  =    positions[0]
									a__ :str						  =    sys.maxsize
									self.top_to_bottom(__A   ,     0   ,     len(__A						)   ,     __A						)
									return temp






def 				lowerCamelCase__	(      a	:   Any				)    ->	Union[str, Any]:





			"""simple docstring"""
			a__ :Tuple						  =    Heap()

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

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

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

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


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


