

import flax.linen as nn
import jax
import jax.numpy as jnp





class 					__lowerCAmelCase	(   nn.Module				):
  _a		     =    42
  _a		     =    jnp.floataa




  def     A__	(							self   )    ->					Union[str, Any]:
        '''simple docstring'''






        _lowercase      			=nn.Conv(
            self.out_channels				,  kernel_size=(3, 3)				,  strides=(1, 1)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )




  def __call__(							self				,  lowerCAmelCase   )    ->					Any:
        '''simple docstring'''






        _lowercase      			=hidden_states.shape
        _lowercase      			=jax.image.resize(
            SCREAMING_SNAKE_CASE_				,  shape=(batch, height * 2, width * 2, channels)				,  method='nearest'				,  )
        _lowercase      			=self.conv(SCREAMING_SNAKE_CASE_   )
        return hidden_states





class 					__lowerCAmelCase	(   nn.Module				):
  _a		     =    42
  _a		     =    jnp.floataa




  def     A__	(							self   )    ->					List[str]:
        '''simple docstring'''






        _lowercase      			=nn.Conv(
            self.out_channels				,  kernel_size=(3, 3)				,  strides=(2, 2)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )




  def __call__(							self				,  lowerCAmelCase   )    ->					List[str]:
        '''simple docstring'''






        _lowercase      			=self.conv(SCREAMING_SNAKE_CASE_   )
        return hidden_states





class 					__lowerCAmelCase	(   nn.Module				):
  _a		     =    42
  _a		     =    None
  _a		     =    0.0
  _a		     =    None
  _a		     =    jnp.floataa




  def     A__	(							self   )    ->					Optional[int]:
        '''simple docstring'''






        _lowercase      			=self.in_channels if self.out_channels is None else self.out_channels

        _lowercase      			=nn.GroupNorm(num_groups=32				,  epsilon=1e-5   )
        _lowercase      			=nn.Conv(
            SCREAMING_SNAKE_CASE_				,  kernel_size=(3, 3)				,  strides=(1, 1)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )

        _lowercase      			=nn.Dense(SCREAMING_SNAKE_CASE_				,  dtype=self.dtype   )

        _lowercase      			=nn.GroupNorm(num_groups=32				,  epsilon=1e-5   )
        _lowercase      			=nn.Dropout(self.dropout_prob   )
        _lowercase      			=nn.Conv(
            SCREAMING_SNAKE_CASE_				,  kernel_size=(3, 3)				,  strides=(1, 1)				,  padding=((1, 1), (1, 1))				,  dtype=self.dtype				,  )

        _lowercase      			=self.in_channels != out_channels if self.use_nin_shortcut is None else self.use_nin_shortcut

        _lowercase      			=None
        if use_nin_shortcut:
              _lowercase      			=nn.Conv(
                  SCREAMING_SNAKE_CASE_				,  kernel_size=(1, 1)				,  strides=(1, 1)				,  padding='VALID'				,  dtype=self.dtype				,  )




  def __call__(							self				,  lowerCAmelCase				,  lowerCAmelCase				,  lowerCAmelCase=True   )    ->					Tuple:
        '''simple docstring'''






        _lowercase      			=hidden_states
        _lowercase      			=self.norma(SCREAMING_SNAKE_CASE_   )
        _lowercase      			=nn.swish(SCREAMING_SNAKE_CASE_   )
        _lowercase      			=self.conva(SCREAMING_SNAKE_CASE_   )

        _lowercase      			=self.time_emb_proj(nn.swish(SCREAMING_SNAKE_CASE_   )   )
        _lowercase      			=jnp.expand_dims(jnp.expand_dims(SCREAMING_SNAKE_CASE_				,  1   )				,  1   )
        _lowercase      			=hidden_states + temb

        _lowercase      			=self.norma(SCREAMING_SNAKE_CASE_   )
        _lowercase      			=nn.swish(SCREAMING_SNAKE_CASE_   )
        _lowercase      			=self.dropout(SCREAMING_SNAKE_CASE_				,  SCREAMING_SNAKE_CASE_   )
        _lowercase      			=self.conva(SCREAMING_SNAKE_CASE_   )

        if self.conv_shortcut is not None:
              _lowercase      			=self.conv_shortcut(SCREAMING_SNAKE_CASE_   )

        return hidden_states + residual






'''simple docstring'''



import sys
from collections import defaultdict





class   UpperCAmelCase_    :





    """simple docstring"""






    def __init__(				self      )							->	int:
         __lowerCamelCase  :      Any														=						[]







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_      )							->	Any:
         return self.node_position[vertex]







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Tuple:
         __lowerCamelCase  :      Optional[int]														=						pos







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	int:
         if start > size // 2 - 1:
              return
         else:
              if 2 * start + 2 >= size:
                   __lowerCamelCase  :      str														=						2 * start + 1
              else:
                   if heap[2 * start + 1] < heap[2 * start + 2]:
                        __lowerCamelCase  :      Optional[Any]														=						2 * start + 1
                   else:
                        __lowerCamelCase  :      int														=						2 * start + 2
              if heap[smallest_child] < heap[start]:
                   __lowerCamelCase							,			__lowerCamelCase  :      Optional[Any]														=						heap[smallest_child], positions[smallest_child]
                   __lowerCamelCase							,			__lowerCamelCase  :      int														=						(
                       heap[start],
                       positions[start],
                   )
                   __lowerCamelCase							,			__lowerCamelCase  :      str														=						temp, tempa

                   __lowerCamelCase  :      Dict														=						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  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Any:
         __lowerCamelCase  :      Any														=						position[index]

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

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







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Optional[int]:
         __lowerCamelCase  :      Optional[int]														=						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  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	List[Any]:
         __lowerCamelCase  :      Any														=						positions[0]
         __lowerCamelCase  :      Union[str, Any]														=						sys.maxsize
         self.top_to_bottom(SCREAMING_SNAKE_CASE_     ,	0     ,	len(SCREAMING_SNAKE_CASE_      )     ,	SCREAMING_SNAKE_CASE_      )
         return temp







def      UpperCAmelCase__   (      UpperCAmelCase_       :							Optional[int]				)	->						str:
     __lowerCamelCase  :      List[Any]														=						Heap()

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

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

     __lowerCamelCase  :      Tuple														=						[]
     __lowerCamelCase  :      Dict														=						1
     __lowerCamelCase  :      str														=						sys.maxsize
     for neighbor, distance in adjacency_list[0]:
          __lowerCamelCase  :      Any														=						0
          __lowerCamelCase  :      Any														=						distance
     heap.heapify(UpperCAmelCase_ ,       UpperCAmelCase_				)

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


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






