






import json
import os
import unittest

from transformers import HerbertTokenizer, HerbertTokenizerFast
from transformers.models.herbert.tokenization_herbert import VOCAB_FILES_NAMES
from transformers.testing_utils import get_tests_dir, require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin




@require_tokenizers
class        snake_case_					(						__UpperCamelCase		,       unittest.TestCase			):

						"""simple docstring"""



						snake_case__   					=			HerbertTokenizer
						snake_case__   					=			HerbertTokenizerFast
						snake_case__   					=			True



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




											'''simple docstring'''



											super().setUp()

											# Use a simpler test file without japanese/chinese characters
											with open(f'{get_tests_dir()}/fixtures/sample_text_no_unicode.txt'   ,				encoding="utf-8"      ) as f_data:
																__a				:	str			=				f_data.read().replace("\n\n"   ,				"\n"      ).strip()

											__a				:	int			=				[
											    "<s>",
											    "</s>",
											    "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>",
											    ",</w>",
											    "<unk>",
											]
											__a				:	Optional[int]			=				dict(zip(__UpperCAmelCase   ,				range(len(__UpperCAmelCase      )      )      )      )
											__a				:	List[Any]			=				["l o 123", "lo w 1456", "e r</w> 1789", ""]

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



						def 					UpperCAmelCase__				(self:				List[str]   ,				__UpperCAmelCase:				Dict      )						->    Union[str, Any]:




											'''simple docstring'''



											__a				:	Optional[int]			=				"lower newer"
											__a				:	Optional[int]			=				"lower newer"
											return input_text, output_text



						def 					UpperCAmelCase__				(self:				Tuple      )						->    List[str]:




											'''simple docstring'''



											__a				:	List[Any]			=				self.tokenizer_class(vocab_file=self.vocab_file   ,				merges_file=self.merges_file      )

											__a				:	Optional[int]			=				"lower"
											__a				:	Tuple			=				["low", "er</w>"]
											__a				:	int			=				tokenizer.tokenize(__UpperCAmelCase      )
											self.assertListEqual(__UpperCAmelCase   ,				__UpperCAmelCase      )

											__a				:	Optional[int]			=				tokens + ["<unk>"]
											__a				:	Dict			=				[16, 17, 23]
											self.assertListEqual(tokenizer.convert_tokens_to_ids(__UpperCAmelCase      )   ,				__UpperCAmelCase      )



						def 					UpperCAmelCase__				(self:				Any      )						->    List[str]:




											'''simple docstring'''



											if not self.test_rust_tokenizer:
																return

											__a				:	Optional[int]			=				self.get_tokenizer()
											__a				:	Tuple			=				self.get_rust_tokenizer()

											__a				:	Any			=				"lower,newer"

											__a				:	List[Any]			=				tokenizer.tokenize(__UpperCAmelCase      )
											__a				:	Tuple			=				rust_tokenizer.tokenize(__UpperCAmelCase      )
											self.assertListEqual(__UpperCAmelCase   ,				__UpperCAmelCase      )

											__a				:	str			=				tokenizer.encode(__UpperCAmelCase   ,				add_special_tokens=__UpperCAmelCase      )
											__a				:	Dict			=				rust_tokenizer.encode(__UpperCAmelCase   ,				add_special_tokens=__UpperCAmelCase      )
											self.assertListEqual(__UpperCAmelCase   ,				__UpperCAmelCase      )

											__a				:	int			=				self.get_rust_tokenizer()
											__a				:	List[Any]			=				tokenizer.encode(__UpperCAmelCase      )
											__a				:	Tuple			=				rust_tokenizer.encode(__UpperCAmelCase      )
											self.assertListEqual(__UpperCAmelCase   ,				__UpperCAmelCase      )



						@slow
						def 					UpperCAmelCase__				(self:				Dict      )						->    Optional[Any]:




											'''simple docstring'''



											__a				:	Optional[int]			=				self.tokenizer_class.from_pretrained("allegro/herbert-base-cased"      )

											__a				:	Tuple			=				tokenizer.encode("konstruowanie sekwencji"   ,				add_special_tokens=__UpperCAmelCase      )
											__a				:	int			=				tokenizer.encode("konstruowanie wielu sekwencji"   ,				add_special_tokens=__UpperCAmelCase      )

											__a				:	Dict			=				tokenizer.build_inputs_with_special_tokens(__UpperCAmelCase      )
											__a				:	Any			=				tokenizer.build_inputs_with_special_tokens(__UpperCAmelCase   ,				__UpperCAmelCase      )

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













def 						a_      (__A							,					__A			)							->	list[tuple[int, int, int]]:



					"""simple docstring"""
					__a				:	str			=				sorted(__A							,					key=lambda __A			: edge[2]			)

					__a				:	int			=				list(range(__A			)			)

					def find_parent(__A			):
										if i != parent[i]:
															__a				:	Optional[Any]			=				find_parent(parent[i]			)
										return parent[i]

					__a				:	Any			=				0
					__a				:	Optional[int]			=				[]

					for edge in edges:
										__a				:	Any			=				find_parent(edge[0]			)
										__a				:	Optional[Any]			=				find_parent(edge[1]			)
										if parent_a != parent_b:
															minimum_spanning_tree_cost += edge[2]
															minimum_spanning_tree.append(__A			)
															__a				:	List[str]			=				parent_b

					return minimum_spanning_tree


if __name__ == "__main__":  # pragma: no cover
			UpperCAmelCase__ ,       UpperCAmelCase__			 =	list(map(int, input().strip().split()))
			UpperCAmelCase__			 =	[]

			for _ in range(num_edges):
						UpperCAmelCase__ ,       UpperCAmelCase__ ,       UpperCAmelCase__			 =	(int(x) for x in input().strip().split())
						edges.append((nodea, nodea, cost))

			kruskal(num_nodes, edges)





