'''simple docstring'''





import sys
from collections import defaultdict




class 			__A :



    def __init__(self       :       str					):
         UpperCAmelCase_			       =  []



    def    _lowercase		(self       :       Tuple  ,     __a       :       Tuple					):
         return self.node_position[vertex]



    def    _lowercase		(self       :       Any  ,     __a       :       List[Any]  ,     __a       :       Optional[Any]					):
         UpperCAmelCase_			       =  pos



    def    _lowercase		(self       :       Dict  ,     __a       :       Union[str, Any]  ,     __a       :       str  ,     __a       :       str  ,     __a       :       Dict					):
         if start > size // 2 - 1:
              return
         else:
              if 2 * start + 2 >= size:
                   UpperCAmelCase_			       =  2 * start + 1
              else:
                   if heap[2 * start + 1] < heap[2 * start + 2]:
                        UpperCAmelCase_			       =  2 * start + 1
                   else:
                        UpperCAmelCase_			       =  2 * start + 2
              if heap[smallest_child] < heap[start]:
                   UpperCAmelCase_       ,					UpperCAmelCase_			       =  heap[smallest_child], positions[smallest_child]
                   UpperCAmelCase_       ,					UpperCAmelCase_			       =  (
                       heap[start],
                       positions[start],
                   )
                   UpperCAmelCase_       ,					UpperCAmelCase_			       =  temp, tempa

                   UpperCAmelCase_			       =  self.get_position(positions[smallest_child]					)
                   self.set_position(
                       positions[smallest_child]  ,     self.get_position(positions[start]					)					)
                   self.set_position(positions[start]  ,     __a					)

                   self.top_to_bottom(__a  ,     __a  ,     __a  ,     __a					)



    def    _lowercase		(self       :       int  ,     __a       :       Dict  ,     __a       :       Tuple  ,     __a       :       str  ,     __a       :       int					):
         UpperCAmelCase_			       =  position[index]

         while index != 0:
              UpperCAmelCase_			       =  int((index - 2) / 2					) if index % 2 == 0 else int((index - 1) / 2					)

              if val < heap[parent]:
                   UpperCAmelCase_			       =  heap[parent]
                   UpperCAmelCase_			       =  position[parent]
                   self.set_position(position[parent]  ,     __a					)
              else:
                   UpperCAmelCase_			       =  val
                   UpperCAmelCase_			       =  temp
                   self.set_position(__a  ,     __a					)
                   break
              UpperCAmelCase_			       =  parent
         else:
              UpperCAmelCase_			       =  val
              UpperCAmelCase_			       =  temp
              self.set_position(__a  ,     0					)



    def    _lowercase		(self       :       Any  ,     __a       :       Optional[Any]  ,     __a       :       Any					):
         UpperCAmelCase_			       =  len(__a					) // 2 - 1
         for i in range(__a  ,     -1  ,     -1					):
              self.top_to_bottom(__a  ,     __a  ,     len(__a					)  ,     __a					)






    def    _lowercase		(self       :       Union[str, Any]  ,     __a       :       Optional[Any]  ,     __a       :       Union[str, Any]					):
         UpperCAmelCase_			       =  positions[0]
         UpperCAmelCase_			       =  sys.maxsize
         self.top_to_bottom(__a  ,     0  ,     len(__a					)  ,     __a					)
         return temp





def       lowerCAmelCase_							(   snake_case_			:					List[Any]     )       -> List[Any]:


     '''simple docstring'''




     UpperCAmelCase_			       =  Heap()

     UpperCAmelCase_			       =  [0] * len(snake_case_     )
     UpperCAmelCase_			       =  [-1] * len(snake_case_     )  # Neighboring Tree Vertex of selected vertex
     # Minimum Distance of explored vertex with neighboring vertex of partial tree
     # formed in graph
     UpperCAmelCase_			       =  []  # Heap of Distance of vertices from their neighboring vertex
     UpperCAmelCase_			       =  []

     for vertex in range(len(snake_case_     )     ):
          distance_tv.append(sys.maxsize     )
          positions.append(snake_case_     )
          heap.node_position.append(snake_case_     )

     UpperCAmelCase_			       =  []
     UpperCAmelCase_			       =  1
     UpperCAmelCase_			       =  sys.maxsize
     for neighbor, distance in adjacency_list[0]:
          UpperCAmelCase_			       =  0
          UpperCAmelCase_			       =  distance
     heap.heapify(snake_case_   ,       snake_case_     )

     for _ in range(1   ,       len(snake_case_     )     ):
          UpperCAmelCase_			       =  heap.delete_minimum(snake_case_   ,       snake_case_     )
          if visited[vertex] == 0:
               tree_edges.append((nbr_tv[vertex], vertex)     )
               UpperCAmelCase_			       =  1
               for neighbor, distance in adjacency_list[vertex]:
                    if (
                        visited[neighbor] == 0
                        and distance < distance_tv[heap.get_position(snake_case_     )]
                    ):
                         UpperCAmelCase_			       =  distance
                         heap.bottom_to_top(
                             snake_case_   ,       heap.get_position(snake_case_     )   ,       snake_case_   ,       snake_case_     )
                         UpperCAmelCase_			       =  vertex
     return tree_edges


if __name__ == "__main__":  # pragma: no cover
    # < --------- Prims Algorithm --------- >
    SCREAMING_SNAKE_CASE_:	List[str]    =int(input('Enter number of edges: ').strip())
    SCREAMING_SNAKE_CASE_:	Tuple    =defaultdict(list)
    for _ in range(edges_number):
        SCREAMING_SNAKE_CASE_:	str    =[int(x) for x in input().strip().split()]
        adjacency_list[edge[0]].append([edge[1], edge[2]])
        adjacency_list[edge[1]].append([edge[0], edge[2]])
    print(prisms_algorithm(adjacency_list))










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_image_inputs


if is_torch_available():
  import torch

if is_vision_available():
  from PIL import Image

  from transformers import ViTImageProcessor


class 							UpperCamelCase_       (					unittest.TestCase	):

    '''simple docstring'''






    def __init__(     self :      Tuple   ,					UpperCAmelCase__ :      List[str]   ,					UpperCAmelCase__ :      int=13   ,					UpperCAmelCase__ :      Union[str, Any]=3   ,					UpperCAmelCase__ :      str=224   ,					UpperCAmelCase__ :      str=30   ,					UpperCAmelCase__ :      Tuple=400   ,					UpperCAmelCase__ :      int=True   ,					UpperCAmelCase__ :      Dict=None   ,					UpperCAmelCase__ :      List[Any]=True   ,					UpperCAmelCase__ :      Union[str, Any]=[0.5, 0.5, 0.5]   ,					UpperCAmelCase__ :      Tuple=[0.5, 0.5, 0.5]   ,					)		->str:





           '''simple docstring'''

           A__ 					=       size if size is not None else {'''height''': 18, '''width''': 18}
           A__ 					=       parent
           A__ 					=       batch_size
           A__ 					=       num_channels
           A__ 					=       image_size
           A__ 					=       min_resolution
           A__ 					=       max_resolution
           A__ 					=       do_resize
           A__ 					=       size
           A__ 					=       do_normalize
           A__ 					=       image_mean
           A__ 					=       image_std





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





           '''simple docstring'''

           return {
               "image_mean": self.image_mean,
               "image_std": self.image_std,
               "do_normalize": self.do_normalize,
               "do_resize": self.do_resize,
               "size": self.size,
           }


@require_torch
@require_vision
class 							UpperCamelCase_       (					UpperCAmelCase__						,   unittest.TestCase	):

    '''simple docstring'''






    UpperCAmelCase__				    = ViTImageProcessor if is_vision_available() else None


    def 			SCREAMING_SNAKE_CASE				(     self :      List[str])		->str:





           '''simple docstring'''

           A__ 					=       EfficientFormerImageProcessorTester(self)


    @property
    def 			SCREAMING_SNAKE_CASE				(     self :      Dict)		->int:





           '''simple docstring'''

           return self.image_proc_tester.prepare_image_processor_dict()


    def 			SCREAMING_SNAKE_CASE				(     self :      Optional[Any])		->Dict:





           '''simple docstring'''

           A__ 					=       self.image_processing_class(**self.image_processor_dict)
           self.assertTrue(hasattr(UpperCAmelCase__   ,					'''image_mean'''))
           self.assertTrue(hasattr(UpperCAmelCase__   ,					'''image_std'''))
           self.assertTrue(hasattr(UpperCAmelCase__   ,					'''do_normalize'''))
           self.assertTrue(hasattr(UpperCAmelCase__   ,					'''do_resize'''))
           self.assertTrue(hasattr(UpperCAmelCase__   ,					'''size'''))


    def 			SCREAMING_SNAKE_CASE				(     self :      List[str])		->Dict:





           '''simple docstring'''

           pass


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





           '''simple docstring'''

           A__ 					=       self.image_processing_class(**self.image_processor_dict)
           # create random PIL images
           A__ 					=       prepare_image_inputs(self.image_proc_tester   ,					equal_resolution=UpperCAmelCase__)
           for image in image_inputs:
                  self.assertIsInstance(UpperCAmelCase__   ,					Image.Image)

           # Test not batched input
           A__ 					=       image_processor(image_inputs[0]   ,					return_tensors='''pt''').pixel_values
           self.assertEqual(
               encoded_images.shape   ,					(
                   1,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size['''height'''],
                   self.image_proc_tester.size['''width'''],
               )   ,					)

           # Test batched
           A__ 					=       image_processor(UpperCAmelCase__   ,					return_tensors='''pt''').pixel_values
           self.assertEqual(
               encoded_images.shape   ,					(
                   self.image_proc_tester.batch_size,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size['''height'''],
                   self.image_proc_tester.size['''width'''],
               )   ,					)


    def 			SCREAMING_SNAKE_CASE				(     self :      Tuple)		->List[Any]:





           '''simple docstring'''

           A__ 					=       self.image_processing_class(**self.image_processor_dict)
           # create random numpy tensors
           A__ 					=       prepare_image_inputs(self.image_proc_tester   ,					equal_resolution=UpperCAmelCase__   ,					numpify=UpperCAmelCase__)
           for image in image_inputs:
                  self.assertIsInstance(UpperCAmelCase__   ,					np.ndarray)

           # Test not batched input
           A__ 					=       image_processor(image_inputs[0]   ,					return_tensors='''pt''').pixel_values
           self.assertEqual(
               encoded_images.shape   ,					(
                   1,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size['''height'''],
                   self.image_proc_tester.size['''width'''],
               )   ,					)

           # Test batched
           A__ 					=       image_processor(UpperCAmelCase__   ,					return_tensors='''pt''').pixel_values
           self.assertEqual(
               encoded_images.shape   ,					(
                   self.image_proc_tester.batch_size,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size['''height'''],
                   self.image_proc_tester.size['''width'''],
               )   ,					)





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





           '''simple docstring'''

           A__ 					=       self.image_processing_class(**self.image_processor_dict)
           # create random PyTorch tensors
           A__ 					=       prepare_image_inputs(self.image_proc_tester   ,					equal_resolution=UpperCAmelCase__   ,					torchify=UpperCAmelCase__)
           for image in image_inputs:
                  self.assertIsInstance(UpperCAmelCase__   ,					torch.Tensor)

           # Test not batched input
           A__ 					=       image_processor(image_inputs[0]   ,					return_tensors='''pt''').pixel_values
           self.assertEqual(
               encoded_images.shape   ,					(
                   1,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size['''height'''],
                   self.image_proc_tester.size['''width'''],
               )   ,					)

           # Test batched
           A__ 					=       image_processor(UpperCAmelCase__   ,					return_tensors='''pt''').pixel_values
           self.assertEqual(
               encoded_images.shape   ,					(
                   self.image_proc_tester.batch_size,
                   self.image_proc_tester.num_channels,
                   self.image_proc_tester.size['''height'''],
                   self.image_proc_tester.size['''width'''],
               )   ,					)


