'''simple docstring'''




import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import VideoMAEImageProcessor

class      lowerCamelCase_     (unittest.TestCase   ):
      '''simple docstring'''

      def __init__(	self						:    List[str]						, A						:    Any						, A						:    Tuple=7						, A						:    Dict=3						, A						:    Union[str, Any]=10						, A						:    Optional[int]=18						, A						:    List[str]=30						, A						:    List[str]=400						, A						:    Optional[int]=True						, A						:    str=None						, A						:    Dict=True						, A						:    Any=[0.5, 0.5, 0.5]						, A						:    Optional[int]=[0.5, 0.5, 0.5]						, A						:    Optional[int]=None						, ):
             _UpperCAmelCase					:  int											=   size if size is not None else {"shortest_edge": 18}
             _UpperCAmelCase					:  str											=   crop_size if crop_size is not None else {"height": 18, "width": 18}

             _UpperCAmelCase					:  Tuple											=   parent
             _UpperCAmelCase					:  List[str]											=   batch_size
             _UpperCAmelCase					:  int											=   num_channels
             _UpperCAmelCase					:  str											=   num_frames
             _UpperCAmelCase					:  Dict											=   image_size
             _UpperCAmelCase					:  Optional[int]											=   min_resolution
             _UpperCAmelCase					:  Union[str, Any]											=   max_resolution
             _UpperCAmelCase					:  Tuple											=   do_resize
             _UpperCAmelCase					:  Dict											=   size
             _UpperCAmelCase					:  Dict											=   do_normalize
             _UpperCAmelCase					:  Any											=   image_mean
             _UpperCAmelCase					:  str											=   image_std
             _UpperCAmelCase					:  Optional[int]											=   crop_size





      def 					_A     (	self						:    int	):
             return {
                 "image_mean": self.image_mean,
                 "image_std": self.image_std,
                 "do_normalize": self.do_normalize,
                 "do_resize": self.do_resize,
                 "size": self.size,
                 "crop_size": self.crop_size,
             }

@require_torch
@require_vision
class      lowerCamelCase_     (snake_case__							,			unittest.TestCase   ):
      '''simple docstring'''

      __UpperCamelCase:  Union[str, Any]      =						VideoMAEImageProcessor if is_vision_available() else None




      def 					_A     (	self						:    Optional[int]	):
             _UpperCAmelCase					:  Optional[int]											=   VideoMAEImageProcessingTester(self	)




      @property
      def 					_A     (	self						:    Optional[int]	):
             return self.image_processor_tester.prepare_image_processor_dict()




      def 					_A     (	self						:    List[str]	):
             _UpperCAmelCase					:  Union[str, Any]											=   self.image_processing_class(**self.image_processor_dict	)
             self.assertTrue(hasattr(A						, "image_mean"	)	)
             self.assertTrue(hasattr(A						, "image_std"	)	)
             self.assertTrue(hasattr(A						, "do_normalize"	)	)
             self.assertTrue(hasattr(A						, "do_resize"	)	)
             self.assertTrue(hasattr(A						, "do_center_crop"	)	)
             self.assertTrue(hasattr(A						, "size"	)	)




      def 					_A     (	self						:    Any	):
             _UpperCAmelCase					:  List[Any]											=   self.image_processing_class.from_dict(self.image_processor_dict	)
             self.assertEqual(image_processor.size						, {"shortest_edge": 18}	)
             self.assertEqual(image_processor.crop_size						, {"height": 18, "width": 18}	)

             _UpperCAmelCase					:  List[str]											=   self.image_processing_class.from_dict(self.image_processor_dict						, size=42						, crop_size=84	)
             self.assertEqual(image_processor.size						, {"shortest_edge": 42}	)
             self.assertEqual(image_processor.crop_size						, {"height": 84, "width": 84}	)




      def 					_A     (	self						:    Tuple	):
             pass




      def 					_A     (	self						:    Optional[int]	):
             # Initialize image_processing
             _UpperCAmelCase					:  List[Any]											=   self.image_processing_class(**self.image_processor_dict	)
             # create random PIL videos
             _UpperCAmelCase					:  str											=   prepare_video_inputs(self.image_processor_tester						, equal_resolution=A	)
             for video in video_inputs:
                    self.assertIsInstance(A						, A	)
                    self.assertIsInstance(video[0]						, Image.Image	)

             # Test not batched input
             _UpperCAmelCase					:  List[str]											=   image_processing(video_inputs[0]						, return_tensors="pt"	).pixel_values
             self.assertEqual(
                 encoded_videos.shape						, (
                     1,
                     self.image_processor_tester.num_frames,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size["height"],
                     self.image_processor_tester.crop_size["width"],
                 )						, )

             # Test batched
             _UpperCAmelCase					:  Union[str, Any]											=   image_processing(A						, return_tensors="pt"	).pixel_values
             self.assertEqual(
                 encoded_videos.shape						, (
                     self.image_processor_tester.batch_size,
                     self.image_processor_tester.num_frames,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size["height"],
                     self.image_processor_tester.crop_size["width"],
                 )						, )




      def 					_A     (	self						:    List[Any]	):
             # Initialize image_processing
             _UpperCAmelCase					:  Optional[Any]											=   self.image_processing_class(**self.image_processor_dict	)
             # create random numpy tensors
             _UpperCAmelCase					:  List[Any]											=   prepare_video_inputs(self.image_processor_tester						, equal_resolution=A						, numpify=A	)
             for video in video_inputs:
                    self.assertIsInstance(A						, A	)
                    self.assertIsInstance(video[0]						, np.ndarray	)

             # Test not batched input
             _UpperCAmelCase					:  List[str]											=   image_processing(video_inputs[0]						, return_tensors="pt"	).pixel_values
             self.assertEqual(
                 encoded_videos.shape						, (
                     1,
                     self.image_processor_tester.num_frames,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size["height"],
                     self.image_processor_tester.crop_size["width"],
                 )						, )

             # Test batched
             _UpperCAmelCase					:  int											=   image_processing(A						, return_tensors="pt"	).pixel_values
             self.assertEqual(
                 encoded_videos.shape						, (
                     self.image_processor_tester.batch_size,
                     self.image_processor_tester.num_frames,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size["height"],
                     self.image_processor_tester.crop_size["width"],
                 )						, )





      def 					_A     (	self						:    Any	):
             # Initialize image_processing
             _UpperCAmelCase					:  int											=   self.image_processing_class(**self.image_processor_dict	)
             # create random PyTorch tensors
             _UpperCAmelCase					:  Union[str, Any]											=   prepare_video_inputs(self.image_processor_tester						, equal_resolution=A						, torchify=A	)
             for video in video_inputs:
                    self.assertIsInstance(A						, A	)
                    self.assertIsInstance(video[0]						, torch.Tensor	)

             # Test not batched input
             _UpperCAmelCase					:  int											=   image_processing(video_inputs[0]						, return_tensors="pt"	).pixel_values
             self.assertEqual(
                 encoded_videos.shape						, (
                     1,
                     self.image_processor_tester.num_frames,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size["height"],
                     self.image_processor_tester.crop_size["width"],
                 )						, )

             # Test batched
             _UpperCAmelCase					:  str											=   image_processing(A						, return_tensors="pt"	).pixel_values
             self.assertEqual(
                 encoded_videos.shape						, (
                     self.image_processor_tester.batch_size,
                     self.image_processor_tester.num_frames,
                     self.image_processor_tester.num_channels,
                     self.image_processor_tester.crop_size["height"],
                     self.image_processor_tester.crop_size["width"],
                 )						, )


'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int      ,     _UpperCAmelCase  :				list[tuple[int, int, int]]   )   ->   list[tuple[int, int, int]]:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[int]											=   sorted(_UpperCAmelCase      ,     key=lambda _UpperCAmelCase   : edge[2]   )

       _UpperCAmelCase					:  Optional[int]											=   list(range(_UpperCAmelCase   )   )

       def find_parent(_UpperCAmelCase  :				Dict   ):
              if i != parent[i]:
                     _UpperCAmelCase					:  Tuple											=   find_parent(parent[i]   )
              return parent[i]

       _UpperCAmelCase					:  Union[str, Any]											=   0
       _UpperCAmelCase					:  Dict											=   []

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

       return minimum_spanning_tree


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

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

  kruskal(num_nodes, edges)

