


"""simple docstring"""


import os
from shutil import copyfile
from typing import Any, Dict, List, Optional, Tuple

import sentencepiece as spm

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


A     :   Any			    =			logging.get_logger(__name__)

A     :   int			    =			{"vocab_file": "sentencepiece.bpe.model"}

A     :   str			    =			{
    "vocab_file": {
        "moussaKam/mbarthez": "https://huggingface.co/moussaKam/mbarthez/resolve/main/sentencepiece.bpe.model",
        "moussaKam/barthez": "https://huggingface.co/moussaKam/barthez/resolve/main/sentencepiece.bpe.model",
        "moussaKam/barthez-orangesum-title": (
            "https://huggingface.co/moussaKam/barthez-orangesum-title/resolve/main/sentencepiece.bpe.model"
        ),
    },
}

A     :   int			    =			{
    "moussaKam/mbarthez": 1_0_2_4,
    "moussaKam/barthez": 1_0_2_4,
    "moussaKam/barthez-orangesum-title": 1_0_2_4,
}

A     :   int			    =			"▁"
class   _UpperCamelCase  (   lowerCAmelCase__		):
							'''simple docstring'''







							__UpperCAmelCase						:    Any				      =VOCAB_FILES_NAMES
							__UpperCAmelCase						:    int				      =PRETRAINED_VOCAB_FILES_MAP
							__UpperCAmelCase						:    int				      =PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
							__UpperCAmelCase						:    Dict				      =["""input_ids""", """attention_mask"""]

							def __init__(     self    ,   __a    ,   __a="<s>"    ,   __a="</s>"    ,   __a="</s>"    ,   __a="<s>"    ,   __a="<unk>"    ,   __a="<pad>"    ,   __a="<mask>"    ,   __a = None    ,   **__a    ,   ):
										# Mask token behave like a normal word, i.e. include the space before it
										__lowerCAmelCase				    =			AddedToken(__a    ,   lstrip=__a    ,   rstrip=__a	) if isinstance(__a    ,   __a	) else mask_token

										__lowerCAmelCase				    =			{} if sp_model_kwargs is None else sp_model_kwargs

										super().__init__(
										    bos_token=__a    ,   eos_token=__a    ,   unk_token=__a    ,   sep_token=__a    ,   cls_token=__a    ,   pad_token=__a    ,   mask_token=__a    ,   sp_model_kwargs=self.sp_model_kwargs    ,   **__a    ,   )

										__lowerCAmelCase				    =			vocab_file
										__lowerCAmelCase				    =			spm.SentencePieceProcessor(**self.sp_model_kwargs	)
										self.sp_model.Load(str(__a	)	)

										__lowerCAmelCase				    =			{"<s>": 0, "<pad>": 1, "</s>": 2, "<unk>": 3}

										__lowerCAmelCase				    =			len(self.sp_model	) - 1
										__lowerCAmelCase				    =			{v: k for k, v in self.fairseq_tokens_to_ids.items()}

							def 			snake_case				(     self    ,   __a    ,   __a = None	):

										if token_ids_a is None:
													return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
										__lowerCAmelCase				    =			[self.cls_token_id]
										__lowerCAmelCase				    =			[self.sep_token_id]
										return cls + token_ids_a + sep + sep + token_ids_a + sep

							def 			snake_case				(     self    ,   __a    ,   __a = None    ,   __a = False	):
										if already_has_special_tokens:
													return super().get_special_tokens_mask(
													    token_ids_a=__a    ,   token_ids_a=__a    ,   already_has_special_tokens=__a	)

										if token_ids_a is None:
													return [1] + ([0] * len(__a	)) + [1]
										return [1] + ([0] * len(__a	)) + [1, 1] + ([0] * len(__a	)) + [1]

							def 			snake_case				(     self    ,   __a    ,   __a = None	):
										__lowerCAmelCase				    =			[self.sep_token_id]
										__lowerCAmelCase				    =			[self.cls_token_id]

										if token_ids_a is None:
													return len(cls + token_ids_a + sep	) * [0]
										return len(cls + token_ids_a + sep + sep + token_ids_a + sep	) * [0]

							@property
							def 			snake_case				(     self	):
										return len(self.sp_model	)

							def 			snake_case				(     self	):
										__lowerCAmelCase				    =			{self.convert_ids_to_tokens(__a	): i for i in range(self.vocab_size	)}
										vocab.update(self.added_tokens_encoder	)
										return vocab

							def 			snake_case				(     self    ,   __a	):
										return self.sp_model.encode(__a    ,   out_type=__a	)

							def 			snake_case				(     self    ,   __a	):
										if token in self.fairseq_tokens_to_ids:
													return self.fairseq_tokens_to_ids[token]
										__lowerCAmelCase				    =			self.sp_model.PieceToId(__a	)

										return spm_id if spm_id else self.unk_token_id

							def 			snake_case				(     self    ,   __a	):
										if index in self.fairseq_ids_to_tokens:
													return self.fairseq_ids_to_tokens[index]
										return self.sp_model.IdToPiece(__a	)

							def 			snake_case				(     self    ,   __a	):
										__lowerCAmelCase				    =			[]
										__lowerCAmelCase				    =			""
										__lowerCAmelCase				    =			False
										for token in tokens:
													# make sure that special tokens are not decoded using sentencepiece model
													if token in self.all_special_tokens:
																if not prev_is_special:
																			out_string += " "
																out_string += self.sp_model.decode(__a	) + token
																__lowerCAmelCase				    =			True
																__lowerCAmelCase				    =			[]
													else:
																current_sub_tokens.append(__a	)
																__lowerCAmelCase				    =			False
										out_string += self.sp_model.decode(__a	)
										return out_string.strip()

							def __getstate__(     self	):
										__lowerCAmelCase				    =			self.__dict__.copy()
										__lowerCAmelCase				    =			None
										return state

							def __setstate__(     self    ,   __a	):
										__lowerCAmelCase				    =			d

										# for backward compatibility
										if not hasattr(self    ,   "sp_model_kwargs"	):
													__lowerCAmelCase				    =			{}

										__lowerCAmelCase				    =			spm.SentencePieceProcessor(**self.sp_model_kwargs	)
										self.sp_model.Load(self.vocab_file	)



							def 			snake_case				(     self    ,   __a    ,   __a = None	):
										if not os.path.isdir(__a	):
													logger.error(f"Vocabulary path ({save_directory}) should be a directory"	)
													return
										__lowerCAmelCase				    =			os.path.join(
										    __a    ,   (filename_prefix + "-" if filename_prefix else "") + VOCAB_FILES_NAMES["vocab_file"]	)

										if os.path.abspath(self.vocab_file	) != os.path.abspath(__a	) and os.path.isfile(self.vocab_file	):
													copyfile(self.vocab_file    ,   __a	)
										elif not os.path.isfile(self.vocab_file	):
													with open(__a    ,   "wb"	) as fi:
																__lowerCAmelCase				    =			self.sp_model.serialized_model_proto()
																fi.write(__a	)

										return (out_vocab_file,)








"""simple docstring"""


import sys
from collections import defaultdict
class   _UpperCamelCase  :
							'''simple docstring'''







							def __init__(     self	):
										__lowerCAmelCase				    =			[]

							def 			snake_case				(     self    ,   __a	):
										return self.node_position[vertex]

							def 			snake_case				(     self    ,   __a    ,   __a	):
										__lowerCAmelCase				    =			pos

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

																__lowerCAmelCase				    =			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    ,   __a    ,   __a    ,   __a    ,   __a	):
										__lowerCAmelCase				    =			position[index]

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

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

							def 			snake_case				(     self    ,   __a    ,   __a	):
										__lowerCAmelCase				    =			len(__a	) // 2 - 1
										for i in range(__a    ,   -1    ,   -1	):
													self.top_to_bottom(__a    ,   __a    ,   len(__a	)    ,   __a	)



							def 			snake_case				(     self    ,   __a    ,   __a	):
										__lowerCAmelCase				    =			positions[0]
										__lowerCAmelCase				    =			sys.maxsize
										self.top_to_bottom(__a    ,   0    ,   len(__a	)    ,   __a	)
										return temp


def _lowerCamelCase	(		_UpperCamelCase      ):

			'''simple docstring'''




			__lowerCAmelCase				    =			Heap()

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

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

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

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


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




