

'''simple docstring'''



import sys
from collections import defaultdict



class 				_snake_case					:

  def __init__(				self	):





      '''simple docstring'''

      lowerCAmelCase 						=							[]

  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      return self.node_position[vertex]

  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      lowerCAmelCase 						=							pos

  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      if start > size // 2 - 1:
          return
      else:
          if 2 * start + 2 >= size:
              lowerCAmelCase 						=							2 * start + 1
          else:
              if heap[2 * start + 1] < heap[2 * start + 2]:
                  lowerCAmelCase 						=							2 * start + 1
              else:
                  lowerCAmelCase 						=							2 * start + 2
          if heap[smallest_child] < heap[start]:
              lowerCAmelCase						,   lowerCAmelCase 						=							heap[smallest_child], positions[smallest_child]
              lowerCAmelCase						,   lowerCAmelCase 						=							(
                  heap[start],
                  positions[start],
              )
              lowerCAmelCase						,   lowerCAmelCase 						=							temp, tempa

              lowerCAmelCase 						=							self.get_position(positions[smallest_child]	)
              self.set_position(
                  positions[smallest_child]      , self.get_position(positions[start]	)	)
              self.set_position(positions[start]      , _SCREAMING_SNAKE_CASE	)

              self.top_to_bottom(_SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	)

  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      lowerCAmelCase 						=							position[index]

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

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

  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      lowerCAmelCase 						=							len(_SCREAMING_SNAKE_CASE	) // 2 - 1
      for i in range(_SCREAMING_SNAKE_CASE      , -1      , -1	):
          self.top_to_bottom(_SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE      , len(_SCREAMING_SNAKE_CASE	)      , _SCREAMING_SNAKE_CASE	)


  def   _SCREAMING_SNAKE_CASE				(				self      , _SCREAMING_SNAKE_CASE      , _SCREAMING_SNAKE_CASE	):





      '''simple docstring'''

      lowerCAmelCase 						=							positions[0]
      lowerCAmelCase 						=							sys.maxsize
      self.top_to_bottom(_SCREAMING_SNAKE_CASE      , 0      , len(_SCREAMING_SNAKE_CASE	)      , _SCREAMING_SNAKE_CASE	)
      return temp



def       snake_case   (	snake_case      : int			) ->  Optional[Any]:


    """simple docstring"""


    lowerCAmelCase 						=							Heap()

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

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

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

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


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



from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import torch

from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available



@dataclass
class 				_snake_case					(   a_			):
  SCREAMING_SNAKE_CASE			:       Union[List[np.ndarray], torch.FloatTensor]


try:
     if not (is_transformers_available() and is_torch_available()):
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
     from .pipeline_text_to_video_synth import TextToVideoSDPipeline
     from .pipeline_text_to_video_synth_imgaimg import VideoToVideoSDPipeline  # noqa: F401
     from .pipeline_text_to_video_zero import TextToVideoZeroPipeline





