
def      __UpperCAmelCase    (  snake_case_							:		int				,					snake_case_							:		list[tuple[int, int, int]]				):



	'''simple docstring'''



	UpperCAmelCase:					Any 						=     sorted(snake_case_				,					key=lambda snake_case_				: edge[2]				)

	UpperCAmelCase:					Union[str, Any] 						=     list(range(snake_case_				)				)

	def find_parent(snake_case_							:		List[str]				):
		if i != parent[i]:
			UpperCAmelCase:					Any 						=     find_parent(parent[i]				)
		return parent[i]

	UpperCAmelCase:					List[str] 						=     0
	UpperCAmelCase:					str 						=     []

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

	return minimum_spanning_tree


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

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

	kruskal(num_nodes, edges)


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


snake_case_      :					Any				      =     {
    'configuration_imagegpt': ['IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ImageGPTConfig', 'ImageGPTOnnxConfig']
}

try:
	if not is_vision_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case_      :					str				      =     ['ImageGPTFeatureExtractor']
	snake_case_      :					Optional[int]				      =     ['ImageGPTImageProcessor']

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	snake_case_      :					List[str]				      =     [
	    'IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST',
	    'ImageGPTForCausalImageModeling',
	    'ImageGPTForImageClassification',
	    'ImageGPTModel',
	    'ImageGPTPreTrainedModel',
	    'load_tf_weights_in_imagegpt',
	]


if TYPE_CHECKING:
	from .configuration_imagegpt import IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, ImageGPTConfig, ImageGPTOnnxConfig

	try:
		if not is_vision_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .feature_extraction_imagegpt import ImageGPTFeatureExtractor
		from .image_processing_imagegpt import ImageGPTImageProcessor

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_imagegpt import (
		    IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST,
		    ImageGPTForCausalImageModeling,
		    ImageGPTForImageClassification,
		    ImageGPTModel,
		    ImageGPTPreTrainedModel,
		    load_tf_weights_in_imagegpt,
		)

else:
	import sys

	snake_case_      :					Dict				      =     _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)
