





import sys
from collections import defaultdict



class 					A__   :





      def __init__( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   []





      def        __UpperCamelCase( self       ,							A_   ):
       '''simple docstring'''




       return self.node_position[vertex]





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   pos





      def        __UpperCamelCase( self       ,							A_       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




       if start > size // 2 - 1:
        return
       else:
        if 2 * start + 2 >= size:
         UpperCamelCase	:					List[Any]       	=   2 * start + 1
        else:
         if heap[2 * start + 1] < heap[2 * start + 2]:
          UpperCamelCase	:					Any       	=   2 * start + 1
         else:
          UpperCamelCase	:					str       	=   2 * start + 2
        if heap[smallest_child] < heap[start]:
         UpperCamelCase	,    UpperCamelCase	:					str       	=   heap[smallest_child], positions[smallest_child]
         UpperCamelCase	,    UpperCamelCase	:					Union[str, Any]       	=   (
             heap[start],
             positions[start],
         )
         UpperCamelCase	,    UpperCamelCase	:					Optional[Any]       	=   temp, tempa

         UpperCamelCase	:					Any       	=   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        __UpperCamelCase( self       ,							A_       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Any       	=   position[index]

       while index != 0:
        UpperCamelCase	:					Optional[Any]       	=   int((index - 2) / 2   ) if index % 2 == 0 else int((index - 1) / 2   )

        if val < heap[parent]:
         UpperCamelCase	:					Dict       	=   heap[parent]
         UpperCamelCase	:					int       	=   position[parent]
         self.set_position(position[parent]       ,							A_   )
        else:
         UpperCamelCase	:					Optional[int]       	=   val
         UpperCamelCase	:					Tuple       	=   temp
         self.set_position(A_       ,							A_   )
         break
        UpperCamelCase	:					List[Any]       	=   parent
       else:
        UpperCamelCase	:					Dict       	=   val
        UpperCamelCase	:					Tuple       	=   temp
        self.set_position(A_       ,							0   )





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Tuple       	=   len(A_   ) // 2 - 1
       for i in range(A_       ,							-1       ,							-1   ):
        self.top_to_bottom(A_       ,							A_       ,							len(A_   )       ,							A_   )





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   positions[0]
       UpperCamelCase	:					Any       	=   sys.maxsize
       self.top_to_bottom(A_       ,							0       ,							len(A_   )       ,							A_   )
       return temp



def 		A_				(     _lowerCAmelCase     )						-> Any:
 UpperCamelCase	:					List[Any]       	=   Heap()

 UpperCamelCase	:					Union[str, Any]       	=   [0] * len(_lowerCAmelCase     )
 UpperCamelCase	:					Union[str, Any]       	=   [-1] * len(_lowerCAmelCase     )  # Neighboring Tree Vertex of selected vertex
 # Minimum Distance of explored vertex with neighboring vertex of partial tree
 # formed in graph
 UpperCamelCase	:					Tuple       	=   []  # Heap of Distance of vertices from their neighboring vertex
 UpperCamelCase	:					Optional[Any]       	=   []

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

 UpperCamelCase	:					int       	=   []
 UpperCamelCase	:					Any       	=   1
 UpperCamelCase	:					List[Any]       	=   sys.maxsize
 for neighbor, distance in adjacency_list[0]:
  UpperCamelCase	:					List[Any]       	=   0
  UpperCamelCase	:					int       	=   distance
 heap.heapify(_lowerCAmelCase							,   _lowerCAmelCase     )

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


if __name__ == "__main__":  # pragma: no cover
    # < --------- Prims Algorithm --------- >
    __lowerCamelCase       :     Any   =     int(input("""Enter number of edges: """).strip())
    __lowerCamelCase       :     Optional[Any]   =     defaultdict(list)
    for _ in range(edges_number):
        __lowerCamelCase       :     Optional[int]   =     [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))




"""simple docstring"""


import numpy as np
from cva import COLOR_BGR2GRAY, cvtColor, imread
from numpy import array, uinta
from PIL import Image

from digital_image_processing import change_contrast as cc
from digital_image_processing import convert_to_negative as cn
from digital_image_processing import sepia as sp
from digital_image_processing.dithering import burkes as bs
from digital_image_processing.edge_detection import canny
from digital_image_processing.filters import convolve as conv
from digital_image_processing.filters import gaussian_filter as gg
from digital_image_processing.filters import local_binary_pattern as lbp
from digital_image_processing.filters import median_filter as med
from digital_image_processing.filters import sobel_filter as sob
from digital_image_processing.resize import resize as rs

A     :   Union[str, Any]			    =			imread(R"digital_image_processing/image_data/lena_small.jpg")
A     :   Optional[Any]			    =			cvtColor(img, COLOR_BGR2GRAY)


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase				    =			cn.convert_to_negative(_UpperCamelCase      )
			# assert negative_img array for at least one True
			assert negative_img.any()


def _lowerCamelCase	(		):

			'''simple docstring'''




			with Image.open("digital_image_processing/image_data/lena_small.jpg"      ) as img:
						# Work around assertion for response
						assert str(cc.change_contrast(_UpperCamelCase    , 110      )      ).startswith(
						    "<PIL.Image.Image image mode=RGB size=100x100 at"      )


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase				    =			canny.gen_gaussian_kernel(9    , sigma=1.4      )
			# Assert ambiguous array
			assert resp.all()


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase				    =			imread("digital_image_processing/image_data/lena_small.jpg"    , 0      )
			# assert ambiguous array for all == True
			assert canny_img.all()
			__lowerCAmelCase				    =			canny.canny(_UpperCamelCase      )
			# assert canny array for at least one True
			assert canny_array.any()


def _lowerCamelCase	(		):

			'''simple docstring'''




			assert gg.gaussian_filter(_UpperCamelCase    , 5    , sigma=0.9      ).all()


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase				    =			array([[0.25, 0.5, 0.25], [0.5, -3, 0.5], [0.25, 0.5, 0.25]]      )
			__lowerCAmelCase				    =			conv.img_convolve(_UpperCamelCase    , _UpperCamelCase      ).astype(_UpperCamelCase      )
			assert res.any()


def _lowerCamelCase	(		):

			'''simple docstring'''




			assert med.median_filter(_UpperCamelCase    , 3      ).any()


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase    ,	__lowerCAmelCase				    =			sob.sobel_filter(_UpperCamelCase      )
			assert grad.any() and theta.any()


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase				    =			sp.make_sepia(_UpperCamelCase    , 20      )
			assert sepia.all()


def _lowerCamelCase	(		_UpperCamelCase = "digital_image_processing/image_data/lena_small.jpg"      ):

			'''simple docstring'''




			__lowerCAmelCase				    =			bs.Burkes(imread(_UpperCamelCase    , 1      )    , 120      )
			burkes.process()
			assert burkes.output_img.any()


def _lowerCamelCase	(		_UpperCamelCase = "digital_image_processing/image_data/lena_small.jpg"    , ):

			'''simple docstring'''




			__lowerCAmelCase				    =			rs.NearestNeighbour(imread(_UpperCamelCase    , 1      )    , 400    , 200      )
			nn.process()
			assert nn.output.any()


def _lowerCamelCase	(		):

			'''simple docstring'''




			__lowerCAmelCase				    =			"digital_image_processing/image_data/lena.jpg"

			# Reading the image and converting it to grayscale.
			__lowerCAmelCase				    =			imread(_UpperCamelCase    , 0      )

			# Test for get_neighbors_pixel function() return not None
			__lowerCAmelCase				    =			0
			__lowerCAmelCase				    =			0
			__lowerCAmelCase				    =			image[x_coordinate][y_coordinate]

			__lowerCAmelCase				    =			lbp.get_neighbors_pixel(
			    _UpperCamelCase    , _UpperCamelCase    , _UpperCamelCase    , _UpperCamelCase      )

			assert neighbors_pixels is not None

			# Test for local_binary_pattern function()
			# Create a numpy array as the same height and width of read image
			__lowerCAmelCase				    =			np.zeros((image.shape[0], image.shape[1])      )

			# Iterating through the image and calculating the local binary pattern value
			# for each pixel.
			for i in range(0    , image.shape[0]      ):
						for j in range(0    , image.shape[1]      ):
									__lowerCAmelCase				    =			lbp.local_binary_value(_UpperCamelCase    , _UpperCamelCase    , _UpperCamelCase      )

			assert lbp_image.any()




