






"""simple docstring"""






import sys
from collections import defaultdict




class 							lowerCAmelCase__				:






      '''simple docstring'''

      def __init__(						self     :  Optional[int]):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Tuple    						=		[]
      def _SCREAMING_SNAKE_CASE (						self     :  Any						,	lowercase_     :  List[Any]):




          '''simple docstring'''


          return self.node_position[vertex]
      def _SCREAMING_SNAKE_CASE (						self     :  Tuple						,	lowercase_     :  Union[str, Any]						,	lowercase_     :  int):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Dict    						=		pos
      def _SCREAMING_SNAKE_CASE (						self     :  str						,	lowercase_     :  List[str]						,	lowercase_     :  str						,	lowercase_     :  str						,	lowercase_     :  Union[str, Any]):




          '''simple docstring'''


          if start > size // 2 - 1:
              return
          else:
              if 2 * start + 2 >= size:
                  SCREAMING_SNAKE_CASE_      :  Any    						=		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_      :  List[Any]    						=		2 * start + 2
              if heap[smallest_child] < heap[start]:
                  SCREAMING_SNAKE_CASE_						,			SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		heap[smallest_child], positions[smallest_child]
                  SCREAMING_SNAKE_CASE_						,			SCREAMING_SNAKE_CASE_      :  Tuple    						=		(
                      heap[start],
                      positions[start],
                  )
                  SCREAMING_SNAKE_CASE_						,			SCREAMING_SNAKE_CASE_      :  Any    						=		temp, tempa

                  SCREAMING_SNAKE_CASE_      :  str    						=		self.get_position(positions[smallest_child])
                  self.set_position(
                      positions[smallest_child]						,	self.get_position(positions[start]))
                  self.set_position(positions[start]						,	lowercase_)

                  self.top_to_bottom(lowercase_						,	lowercase_						,	lowercase_						,	lowercase_)
      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]						,	lowercase_     :  List[Any]						,	lowercase_     :  str						,	lowercase_     :  Dict						,	lowercase_     :  Dict):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		position[index]

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

              if val < heap[parent]:
                  SCREAMING_SNAKE_CASE_      :  int    						=		heap[parent]
                  SCREAMING_SNAKE_CASE_      :  List[Any]    						=		position[parent]
                  self.set_position(position[parent]						,	lowercase_)
              else:
                  SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		val
                  SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		temp
                  self.set_position(lowercase_						,	lowercase_)
                  break
              SCREAMING_SNAKE_CASE_      :  Tuple    						=		parent
          else:
              SCREAMING_SNAKE_CASE_      :  Tuple    						=		val
              SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		temp
              self.set_position(lowercase_						,	0)
      def _SCREAMING_SNAKE_CASE (						self     :  Optional[int]						,	lowercase_     :  List[Any]						,	lowercase_     :  str):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  Union[str, Any]    						=		len(lowercase_) // 2 - 1
          for i in range(lowercase_						,	-1						,	-1):
              self.top_to_bottom(lowercase_						,	lowercase_						,	len(lowercase_)						,	lowercase_)



      def _SCREAMING_SNAKE_CASE (						self     :  List[Any]						,	lowercase_     :  Dict						,	lowercase_     :  int):




          '''simple docstring'''


          SCREAMING_SNAKE_CASE_      :  List[str]    						=		positions[0]
          SCREAMING_SNAKE_CASE_      :  Optional[Any]    						=		sys.maxsize
          self.top_to_bottom(lowercase_						,	0						,	len(lowercase_)						,	lowercase_)
          return temp



def 					_A			(__a							) ->       Optional[Any]:
    """simple docstring"""






    SCREAMING_SNAKE_CASE_      :  int    						=		Heap()

    SCREAMING_SNAKE_CASE_      :  List[Any]    						=		[0] * len(__a							)
    SCREAMING_SNAKE_CASE_      :  List[str]    						=		[-1] * len(__a							)  # 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_      :  List[str]    						=		[]

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

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

    for _ in range(1    ,				len(__a							)							):
        SCREAMING_SNAKE_CASE_      :  Tuple    						=		heap.delete_minimum(__a    ,				__a							)
        if visited[vertex] == 0:
            tree_edges.append((nbr_tv[vertex], vertex)							)
            SCREAMING_SNAKE_CASE_      :  str    						=		1
            for neighbor, distance in adjacency_list[vertex]:
                if (
                    visited[neighbor] == 0
                    and distance < distance_tv[heap.get_position(__a							)]
                ):
                    SCREAMING_SNAKE_CASE_      :  Optional[int]    						=		distance
                    heap.bottom_to_top(
                        __a    ,				heap.get_position(__a							)    ,				__a    ,				__a							)
                    SCREAMING_SNAKE_CASE_      :  Dict    						=		vertex
    return tree_edges


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






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_A		       =						{
    'configuration_jukebox': [
        'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'JukeboxConfig',
        'JukeboxPriorConfig',
        'JukeboxVQVAEConfig',
    ],
    'tokenization_jukebox': ['JukeboxTokenizer'],
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _A		       =						[
       'JUKEBOX_PRETRAINED_MODEL_ARCHIVE_LIST',
       'JukeboxModel',
       'JukeboxPreTrainedModel',
       'JukeboxVQVAE',
       'JukeboxPrior',
   ]

if TYPE_CHECKING:
   from .configuration_jukebox import (
       JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP,
       JukeboxConfig,
       JukeboxPriorConfig,
       JukeboxVQVAEConfig,
   )
   from .tokenization_jukebox import JukeboxTokenizer

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_jukebox import (
          JUKEBOX_PRETRAINED_MODEL_ARCHIVE_LIST,
          JukeboxModel,
          JukeboxPreTrainedModel,
          JukeboxPrior,
          JukeboxVQVAE,
      )

else:
   import sys

   _A		       =						_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)





