






import unittest
from dataclasses import dataclass
from typing import Optional

from transformers.utils import ModelOutput




@dataclass
class        snake_case_					(						__UpperCamelCase			):

						"""simple docstring"""



						snake_case__   					=			42
						snake_case__   					=			None
						snake_case__   					=			None




class        snake_case_					(						unittest.TestCase			):

						"""simple docstring"""



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




											'''simple docstring'''



											__a				:	List[str]			=				ModelOutputTest(a=30      )
											self.assertEqual(x.a   ,				30      )
											self.assertIsNone(x.b      )
											self.assertIsNone(x.c      )
											with self.assertRaises(__UpperCAmelCase      ):
																__a				:	Tuple			=				x.d



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




											'''simple docstring'''



											__a				:	Union[str, Any]			=				ModelOutputTest(a=30   ,				b=10      )
											self.assertEqual(x[0]   ,				30      )
											self.assertEqual(x[1]   ,				10      )
											self.assertEqual(x[:2]   ,				(30, 10)      )
											self.assertEqual(x[:]   ,				(30, 10)      )

											__a				:	int			=				ModelOutputTest(a=30   ,				c=10      )
											self.assertEqual(x[0]   ,				30      )
											self.assertEqual(x[1]   ,				10      )
											self.assertEqual(x[:2]   ,				(30, 10)      )
											self.assertEqual(x[:]   ,				(30, 10)      )



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




											'''simple docstring'''



											__a				:	Optional[Any]			=				ModelOutputTest(a=30   ,				b=10      )
											self.assertEqual(x["a"]   ,				30      )
											self.assertEqual(x["b"]   ,				10      )
											with self.assertRaises(__UpperCAmelCase      ):
																__a				:	List[str]			=				x["c"]

											__a				:	Union[str, Any]			=				ModelOutputTest(a=30   ,				c=10      )
											self.assertEqual(x["a"]   ,				30      )
											self.assertEqual(x["c"]   ,				10      )
											with self.assertRaises(__UpperCAmelCase      ):
																__a				:	int			=				x["b"]



						def 					UpperCAmelCase__				(self:				Union[str, Any]      )						->    Optional[int]:




											'''simple docstring'''



											__a				:	Union[str, Any]			=				ModelOutputTest(a=30      )
											self.assertEqual(list(x.keys()      )   ,				["a"]      )
											self.assertEqual(list(x.values()      )   ,				[30]      )
											self.assertEqual(list(x.items()      )   ,				[("a", 30)]      )
											self.assertEqual(list(__UpperCAmelCase      )   ,				["a"]      )

											__a				:	List[str]			=				ModelOutputTest(a=30   ,				b=10      )
											self.assertEqual(list(x.keys()      )   ,				["a", "b"]      )
											self.assertEqual(list(x.values()      )   ,				[30, 10]      )
											self.assertEqual(list(x.items()      )   ,				[("a", 30), ("b", 10)]      )
											self.assertEqual(list(__UpperCAmelCase      )   ,				["a", "b"]      )

											__a				:	str			=				ModelOutputTest(a=30   ,				c=10      )
											self.assertEqual(list(x.keys()      )   ,				["a", "c"]      )
											self.assertEqual(list(x.values()      )   ,				[30, 10]      )
											self.assertEqual(list(x.items()      )   ,				[("a", 30), ("c", 10)]      )
											self.assertEqual(list(__UpperCAmelCase      )   ,				["a", "c"]      )

											with self.assertRaises(__UpperCAmelCase      ):
																__a				:	Dict			=				x.update({"d": 20}      )
											with self.assertRaises(__UpperCAmelCase      ):
																del x["a"]
											with self.assertRaises(__UpperCAmelCase      ):
																__a				:	Any			=				x.pop("a"      )
											with self.assertRaises(__UpperCAmelCase      ):
																__a				:	Any			=				x.setdefault("d"   ,				32      )



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




											'''simple docstring'''



											__a				:	Optional[Any]			=				ModelOutputTest(a=30      )
											__a				:	int			=				10
											self.assertEqual(x.a   ,				10      )
											self.assertEqual(x["a"]   ,				10      )



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




											'''simple docstring'''



											__a				:	Optional[int]			=				ModelOutputTest(a=30      )
											__a				:	int			=				10
											self.assertEqual(x.a   ,				10      )
											self.assertEqual(x["a"]   ,				10      )



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




											'''simple docstring'''



											__a				:	Dict			=				ModelOutputTest({"a": 30, "b": 10}      )
											self.assertEqual(list(x.keys()      )   ,				["a", "b"]      )
											self.assertEqual(x.a   ,				30      )
											self.assertEqual(x.b   ,				10      )



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




											'''simple docstring'''



											__a				:	List[Any]			=				ModelOutputTest([("a", 30), ("b", 10)]      )
											self.assertEqual(list(x.keys()      )   ,				["a", "b"]      )
											self.assertEqual(x.a   ,				30      )
											self.assertEqual(x.b   ,				10      )

											with self.assertRaises(__UpperCAmelCase      ):
																__a				:	List[Any]			=				ModelOutputTest([("a", 30), (10, 10)]      )

											__a				:	Optional[Any]			=				ModelOutputTest(a=(30, 30)      )
											self.assertEqual(list(x.keys()      )   ,				["a"]      )
											self.assertEqual(x.a   ,				(30, 30)      )













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)





