






import sys
from collections import defaultdict


class  SCREAMING_SNAKE_CASE			:
     '''simple docstring'''


     def __init__(				self       :	List[Any]      ):
       SCREAMING_SNAKE_CASE       :      Optional[int]							=    []


     def 				_A       (				self       :	Any					, UpperCAmelCase_       :	Dict      ):
       return self.node_position[vertex]


     def 				_A       (				self       :	Optional[int]					, UpperCAmelCase_       :	Optional[Any]					, UpperCAmelCase_       :	Optional[Any]      ):
       SCREAMING_SNAKE_CASE       :      List[str]							=    pos


     def 				_A       (				self       :	Any					, UpperCAmelCase_       :	List[Any]					, UpperCAmelCase_       :	Optional[int]					, UpperCAmelCase_       :	Optional[int]					, UpperCAmelCase_       :	Union[str, Any]      ):
       if start > size // 2 - 1:
         return
       else:
         if 2 * start + 2 >= size:
           SCREAMING_SNAKE_CASE       :      List[str]							=    2 * start + 1
         else:
           if heap[2 * start + 1] < heap[2 * start + 2]:
             SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    2 * start + 1
           else:
             SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    2 * start + 2
         if heap[smallest_child] < heap[start]:
           SCREAMING_SNAKE_CASE						,  SCREAMING_SNAKE_CASE       :      Tuple							=    heap[smallest_child], positions[smallest_child]
           SCREAMING_SNAKE_CASE						,  SCREAMING_SNAKE_CASE       :      List[Any]							=    (
               heap[start],
               positions[start],
           )
           SCREAMING_SNAKE_CASE						,  SCREAMING_SNAKE_CASE       :      List[str]							=    temp, tempa

           SCREAMING_SNAKE_CASE       :      Any							=    self.get_position(positions[smallest_child]      )
           self.set_position(
               positions[smallest_child]					, self.get_position(positions[start]      )      )
           self.set_position(positions[start]					, UpperCAmelCase_      )

           self.top_to_bottom(UpperCAmelCase_					, UpperCAmelCase_					, UpperCAmelCase_					, UpperCAmelCase_      )


     def 				_A       (				self       :	int					, UpperCAmelCase_       :	Union[str, Any]					, UpperCAmelCase_       :	Any					, UpperCAmelCase_       :	Optional[int]					, UpperCAmelCase_       :	int      ):
       SCREAMING_SNAKE_CASE       :      str							=    position[index]

       while index != 0:
         SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    int((index - 2) / 2      ) if index % 2 == 0 else int((index - 1) / 2      )

         if val < heap[parent]:
           SCREAMING_SNAKE_CASE       :      str							=    heap[parent]
           SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    position[parent]
           self.set_position(position[parent]					, UpperCAmelCase_      )
         else:
           SCREAMING_SNAKE_CASE       :      Dict							=    val
           SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    temp
           self.set_position(UpperCAmelCase_					, UpperCAmelCase_      )
           break
         SCREAMING_SNAKE_CASE       :      str							=    parent
       else:
         SCREAMING_SNAKE_CASE       :      List[Any]							=    val
         SCREAMING_SNAKE_CASE       :      Tuple							=    temp
         self.set_position(UpperCAmelCase_					, 0      )


     def 				_A       (				self       :	Tuple					, UpperCAmelCase_       :	List[Any]					, UpperCAmelCase_       :	Union[str, Any]      ):
       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    len(UpperCAmelCase_      ) // 2 - 1
       for i in range(UpperCAmelCase_					, -1					, -1      ):
         self.top_to_bottom(UpperCAmelCase_					, UpperCAmelCase_					, len(UpperCAmelCase_      )					, UpperCAmelCase_      )






     def 				_A       (				self       :	Optional[int]					, UpperCAmelCase_       :	Union[str, Any]					, UpperCAmelCase_       :	Optional[Any]      ):
       SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    positions[0]
       SCREAMING_SNAKE_CASE       :      Tuple							=    sys.maxsize
       self.top_to_bottom(UpperCAmelCase_					, 0					, len(UpperCAmelCase_      )					, UpperCAmelCase_      )
       return temp





def   lowerCamelCase__			(     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    Heap()

  SCREAMING_SNAKE_CASE       :      Dict							=    [0] * len(lowercase				)
  SCREAMING_SNAKE_CASE       :      List[str]							=    [-1] * len(lowercase				)  # Neighboring Tree Vertex of selected vertex
  # Minimum Distance of explored vertex with neighboring vertex of partial tree
  # formed in graph
  SCREAMING_SNAKE_CASE       :      Optional[int]							=    []  # Heap of Distance of vertices from their neighboring vertex
  SCREAMING_SNAKE_CASE       :      Any							=    []

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

  SCREAMING_SNAKE_CASE       :      Any							=    []
  SCREAMING_SNAKE_CASE       :      Dict							=    1
  SCREAMING_SNAKE_CASE       :      Any							=    sys.maxsize
  for neighbor, distance in adjacency_list[0]:
    SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    0
    SCREAMING_SNAKE_CASE       :      Optional[int]							=    distance
  heap.heapify(lowercase						,     lowercase				)

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


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

import numpy as np
import torch

from diffusers import StableDiffusionKDiffusionPipeline
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()


@slow
@require_torch_gpu
class  SCREAMING_SNAKE_CASE			(			unittest.TestCase					):
     '''simple docstring'''


     def 				_A       (				self       :	List[Any]      ):
       # clean up the VRAM after each test
       super().tearDown()
       gc.collect()
       torch.cuda.empty_cache()


     def 				_A       (				self       :	str      ):
       SCREAMING_SNAKE_CASE       :      List[str]							=    StableDiffusionKDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4"      )
       SCREAMING_SNAKE_CASE       :      int							=    sd_pipe.to(UpperCAmelCase_      )
       sd_pipe.set_progress_bar_config(disable=UpperCAmelCase_      )

       sd_pipe.set_scheduler("sample_euler"      )

       SCREAMING_SNAKE_CASE       :      str							=    "A painting of a squirrel eating a burger"
       SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    torch.manual_seed(0      )
       SCREAMING_SNAKE_CASE       :      Any							=    sd_pipe([prompt]					, generator=UpperCAmelCase_					, guidance_scale=9.0					, num_inference_steps=20					, output_type="np"      )

       SCREAMING_SNAKE_CASE       :      List[str]							=    output.images

       SCREAMING_SNAKE_CASE       :      str							=    image[0, -3:, -3:, -1]

       assert image.shape == (1, 512, 512, 3)
       SCREAMING_SNAKE_CASE       :      int							=    np.array([0.0_447, 0.0_492, 0.0_468, 0.0_408, 0.0_383, 0.0_408, 0.0_354, 0.0_380, 0.0_339]      )

       assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1E-2


     def 				_A       (				self       :	List[Any]      ):
       SCREAMING_SNAKE_CASE       :      str							=    StableDiffusionKDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base"      )
       SCREAMING_SNAKE_CASE       :      str							=    sd_pipe.to(UpperCAmelCase_      )
       sd_pipe.set_progress_bar_config(disable=UpperCAmelCase_      )

       sd_pipe.set_scheduler("sample_euler"      )

       SCREAMING_SNAKE_CASE       :      List[str]							=    "A painting of a squirrel eating a burger"
       SCREAMING_SNAKE_CASE       :      Dict							=    torch.manual_seed(0      )
       SCREAMING_SNAKE_CASE       :      Optional[int]							=    sd_pipe([prompt]					, generator=UpperCAmelCase_					, guidance_scale=9.0					, num_inference_steps=20					, output_type="np"      )

       SCREAMING_SNAKE_CASE       :      Optional[int]							=    output.images

       SCREAMING_SNAKE_CASE       :      Dict							=    image[0, -3:, -3:, -1]

       assert image.shape == (1, 512, 512, 3)
       SCREAMING_SNAKE_CASE       :      int							=    np.array([0.1_237, 0.1_320, 0.1_438, 0.1_359, 0.1_390, 0.1_132, 0.1_277, 0.1_175, 0.1_112]      )

       assert np.abs(image_slice.flatten() - expected_slice      ).max() < 5E-1






     def 				_A       (				self       :	Optional[int]      ):
       SCREAMING_SNAKE_CASE       :      List[str]							=    StableDiffusionKDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base"      )
       SCREAMING_SNAKE_CASE       :      Any							=    sd_pipe.to(UpperCAmelCase_      )
       sd_pipe.set_progress_bar_config(disable=UpperCAmelCase_      )

       sd_pipe.set_scheduler("sample_dpmpp_2m"      )

       SCREAMING_SNAKE_CASE       :      List[str]							=    "A painting of a squirrel eating a burger"
       SCREAMING_SNAKE_CASE       :      Any							=    torch.manual_seed(0      )
       SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    sd_pipe(
           [prompt]					, generator=UpperCAmelCase_					, guidance_scale=7.5					, num_inference_steps=15					, output_type="np"					, use_karras_sigmas=UpperCAmelCase_					, )

       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    output.images

       SCREAMING_SNAKE_CASE       :      List[Any]							=    image[0, -3:, -3:, -1]

       assert image.shape == (1, 512, 512, 3)
       SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    np.array(
           [0.11_381_689, 0.12_112_921, 0.1_389_457, 0.12_549_606, 0.1_244_964, 0.10_831_517, 0.11_562_866, 0.10_867_816, 0.10_499_048]      )

       assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1E-2






