
"""simple docstring"""







from typing import Any, Callable, Dict, List, Optional, Union

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


lowerCamelCase__     =						logging.get_logger(__name__)  # pylint: disable=invalid-name




class 					A__			(      _lowerCamelCase):
		A_		:			Optional[int]							  =      ['safety_checker', 'feature_extractor']

		def __init__( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE = True			,						):
			super().__init__()
			if hasattr(scheduler.config			,						'steps_offset'					) and scheduler.config.steps_offset != 1:
				__lowerCAmelCase     :		int		     = (
				    f"The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`"
				    f" should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure "
				    'to update the config accordingly as leaving `steps_offset` might led to incorrect results'
				    ' in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,'
				    ' it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`'
				    ' file'
				)
				deprecate('steps_offset!=1'			,						'1.0.0'			,						_SCREAMING_SNAKE_CASE			,						standard_warn=_SCREAMING_SNAKE_CASE					)
				__lowerCAmelCase     :		Dict		     = dict(scheduler.config					)
				__lowerCAmelCase     :		int		     = 1
				__lowerCAmelCase     :		Optional[int]		     = FrozenDict(_SCREAMING_SNAKE_CASE					)

			self.register_modules(
			    vae=_SCREAMING_SNAKE_CASE			,						text_encoder=_SCREAMING_SNAKE_CASE			,						tokenizer=_SCREAMING_SNAKE_CASE			,						unet=_SCREAMING_SNAKE_CASE			,						scheduler=_SCREAMING_SNAKE_CASE			,						safety_checker=_SCREAMING_SNAKE_CASE			,						feature_extractor=_SCREAMING_SNAKE_CASE			,						)
			self.register_to_config(requires_safety_checker=_SCREAMING_SNAKE_CASE					)

		@property
		def 				__lowerCamelCase				( self					):
			return {k: getattr(self			,						_SCREAMING_SNAKE_CASE					) for k in self.config.keys() if not k.startswith('_'					)}

		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE = "auto"					):
			if slice_size == "auto":
				# half the attention head size is usually a good trade-off between
				# speed and memory
				__lowerCAmelCase     :		Union[str, Any]		     = self.unet.config.attention_head_dim // 2
			self.unet.set_attention_slice(_SCREAMING_SNAKE_CASE					)

		def 				__lowerCamelCase				( self					):
			self.enable_attention_slicing(_SCREAMING_SNAKE_CASE					)

		@torch.no_grad()
		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE = 0.8			,						_SCREAMING_SNAKE_CASE = 50			,						_SCREAMING_SNAKE_CASE = 7.5			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						_SCREAMING_SNAKE_CASE = 0.0			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = "pil"			,						_SCREAMING_SNAKE_CASE = True			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						):
			# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
			return StableDiffusionInpaintPipelineLegacy(**self.components					)(
			    prompt=_SCREAMING_SNAKE_CASE			,						image=_SCREAMING_SNAKE_CASE			,						mask_image=_SCREAMING_SNAKE_CASE			,						strength=_SCREAMING_SNAKE_CASE			,						num_inference_steps=_SCREAMING_SNAKE_CASE			,						guidance_scale=_SCREAMING_SNAKE_CASE			,						negative_prompt=_SCREAMING_SNAKE_CASE			,						num_images_per_prompt=_SCREAMING_SNAKE_CASE			,						eta=_SCREAMING_SNAKE_CASE			,						generator=_SCREAMING_SNAKE_CASE			,						output_type=_SCREAMING_SNAKE_CASE			,						return_dict=_SCREAMING_SNAKE_CASE			,						callback=_SCREAMING_SNAKE_CASE			,						)

		@torch.no_grad()
		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE = 0.8			,						_SCREAMING_SNAKE_CASE = 50			,						_SCREAMING_SNAKE_CASE = 7.5			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						_SCREAMING_SNAKE_CASE = 0.0			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = "pil"			,						_SCREAMING_SNAKE_CASE = True			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						**_SCREAMING_SNAKE_CASE			,						):
			# For more information on how this function works, please see: https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionImg2ImgPipeline
			return StableDiffusionImgaImgPipeline(**self.components					)(
			    prompt=_SCREAMING_SNAKE_CASE			,						image=_SCREAMING_SNAKE_CASE			,						strength=_SCREAMING_SNAKE_CASE			,						num_inference_steps=_SCREAMING_SNAKE_CASE			,						guidance_scale=_SCREAMING_SNAKE_CASE			,						negative_prompt=_SCREAMING_SNAKE_CASE			,						num_images_per_prompt=_SCREAMING_SNAKE_CASE			,						eta=_SCREAMING_SNAKE_CASE			,						generator=_SCREAMING_SNAKE_CASE			,						output_type=_SCREAMING_SNAKE_CASE			,						return_dict=_SCREAMING_SNAKE_CASE			,						callback=_SCREAMING_SNAKE_CASE			,						callback_steps=_SCREAMING_SNAKE_CASE			,						)







		@torch.no_grad()
		def 				__lowerCamelCase				( self			,						_SCREAMING_SNAKE_CASE			,						_SCREAMING_SNAKE_CASE = 5_12			,						_SCREAMING_SNAKE_CASE = 5_12			,						_SCREAMING_SNAKE_CASE = 50			,						_SCREAMING_SNAKE_CASE = 7.5			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						_SCREAMING_SNAKE_CASE = 0.0			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = "pil"			,						_SCREAMING_SNAKE_CASE = True			,						_SCREAMING_SNAKE_CASE = None			,						_SCREAMING_SNAKE_CASE = 1			,						):
			# For more information on how this function https://huggingface.co/docs/diffusers/api/pipelines/stable_diffusion#diffusers.StableDiffusionPipeline
			return StableDiffusionPipeline(**self.components					)(
			    prompt=_SCREAMING_SNAKE_CASE			,						height=_SCREAMING_SNAKE_CASE			,						width=_SCREAMING_SNAKE_CASE			,						num_inference_steps=_SCREAMING_SNAKE_CASE			,						guidance_scale=_SCREAMING_SNAKE_CASE			,						negative_prompt=_SCREAMING_SNAKE_CASE			,						num_images_per_prompt=_SCREAMING_SNAKE_CASE			,						eta=_SCREAMING_SNAKE_CASE			,						generator=_SCREAMING_SNAKE_CASE			,						latents=_SCREAMING_SNAKE_CASE			,						output_type=_SCREAMING_SNAKE_CASE			,						return_dict=_SCREAMING_SNAKE_CASE			,						callback=_SCREAMING_SNAKE_CASE			,						callback_steps=_SCREAMING_SNAKE_CASE			,						)

"""simple docstring"""







def        __lowerCAmelCase							(_UpperCamelCase			,    _UpperCamelCase						):
	__lowerCAmelCase     :		Any		     = sorted(_UpperCamelCase			,    key=lambda _UpperCamelCase						: edge[2]						)

	__lowerCAmelCase     :		Union[str, Any]		     = list(range(_UpperCamelCase						)						)

	def find_parent(_UpperCamelCase						):
		if i != parent[i]:
			__lowerCAmelCase     :		int		     = find_parent(parent[i]						)
		return parent[i]

	__lowerCAmelCase     :		Optional[Any]		     = 0
	__lowerCAmelCase     :		List[str]		     = []

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

	return minimum_spanning_tree


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

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

							kruskal(num_nodes, edges)