






"""simple docstring"""







import sys
from collections import defaultdict





class   UpperCamelCase_ :



  def __init__(      self				)			->			Optional[int]:



         """simple docstring"""





         UpperCAmelCase	    =			[]



  def 		UpperCamelCase_				(      self ,		snake_case__				)			->			int:



         """simple docstring"""





         return self.node_position[vertex]



  def 		UpperCamelCase_				(      self ,		snake_case__ ,		snake_case__				)			->			Any:



         """simple docstring"""





         UpperCAmelCase	    =			pos



  def 		UpperCamelCase_				(      self ,		snake_case__ ,		snake_case__ ,		snake_case__ ,		snake_case__				)			->			List[str]:



         """simple docstring"""





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

                       UpperCAmelCase	    =			self.get_position(positions[smallest_child]				)
                       self.set_position(
                           positions[smallest_child] ,		self.get_position(positions[start]				)				)
                       self.set_position(positions[start] ,		snake_case__				)

                       self.top_to_bottom(snake_case__ ,		snake_case__ ,		snake_case__ ,		snake_case__				)



  def 		UpperCamelCase_				(      self ,		snake_case__ ,		snake_case__ ,		snake_case__ ,		snake_case__				)			->			Tuple:



         """simple docstring"""





         UpperCAmelCase	    =			position[index]

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

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



  def 		UpperCamelCase_				(      self ,		snake_case__ ,		snake_case__				)			->			List[str]:



         """simple docstring"""





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



  def 		UpperCamelCase_				(      self ,		snake_case__ ,		snake_case__				)			->			List[str]:



         """simple docstring"""





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






def       _lowerCAmelCase       (      lowerCAmelCase		):







       '''simple docstring'''
       UpperCAmelCase	    =			Heap()

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

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

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

       for _ in range(1	,      len(lowerCAmelCase		)		):
              UpperCAmelCase	    =			heap.delete_minimum(lowerCAmelCase	,      lowerCAmelCase		)
              if visited[vertex] == 0:
                     tree_edges.append((nbr_tv[vertex], vertex)		)
                     UpperCAmelCase	    =			1
                     for neighbor, distance in adjacency_list[vertex]:
                            if (
                                visited[neighbor] == 0
                                and distance < distance_tv[heap.get_position(lowerCAmelCase		)]
                            ):
                                   UpperCAmelCase	    =			distance
                                   heap.bottom_to_top(
                                       lowerCAmelCase	,      heap.get_position(lowerCAmelCase		)	,      lowerCAmelCase	,      lowerCAmelCase		)
                                   UpperCAmelCase	    =			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_	:    Tuple            =      [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 typing import List, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCAmelCase_	:    str            =      logging.get_logger(__name__)

lowerCAmelCase_	:    Optional[int]            =      {
    '''huggingface/time-series-transformer-tourism-monthly''': (
        '''https://huggingface.co/huggingface/time-series-transformer-tourism-monthly/resolve/main/config.json'''
    ),
    # See all TimeSeriesTransformer models at https://huggingface.co/models?filter=time_series_transformer
}





class   UpperCamelCase_ (       a_  ):
  _A       :					int				=	'time_series_transformer'
  _A       :					List[Any]				=	{
      'hidden_size': 'd_model',
      'num_attention_heads': 'encoder_attention_heads',
      'num_hidden_layers': 'encoder_layers',
  }



  def __init__(      self ,		snake_case__ = None ,		snake_case__ = None ,		snake_case__ = "student_t" ,		snake_case__ = "nll" ,		snake_case__ = 1 ,		snake_case__ = [1, 2, 3, 4, 5, 6, 7] ,		snake_case__ = "mean" ,		snake_case__ = 0 ,		snake_case__ = 0 ,		snake_case__ = 0 ,		snake_case__ = 0 ,		snake_case__ = None ,		snake_case__ = None ,		snake_case__ = 32 ,		snake_case__ = 32 ,		snake_case__ = 2 ,		snake_case__ = 2 ,		snake_case__ = 2 ,		snake_case__ = 2 ,		snake_case__ = True ,		snake_case__ = "gelu" ,		snake_case__ = 64 ,		snake_case__ = 0.1 ,		snake_case__ = 0.1 ,		snake_case__ = 0.1 ,		snake_case__ = 0.1 ,		snake_case__ = 0.1 ,		snake_case__ = 1_00 ,		snake_case__ = 0.02 ,		snake_case__=True ,		**snake_case__ ,		)			->			Union[str, Any]:



         """simple docstring"""





         UpperCAmelCase	    =			prediction_length
         UpperCAmelCase	    =			context_length or prediction_length
         UpperCAmelCase	    =			distribution_output
         UpperCAmelCase	    =			loss
         UpperCAmelCase	    =			input_size
         UpperCAmelCase	    =			num_time_features
         UpperCAmelCase	    =			lags_sequence
         UpperCAmelCase	    =			scaling
         UpperCAmelCase	    =			num_dynamic_real_features
         UpperCAmelCase	    =			num_static_real_features
         UpperCAmelCase	    =			num_static_categorical_features
         if cardinality and num_static_categorical_features > 0:
                if len(snake_case__				) != num_static_categorical_features:
                       raise ValueError(
                           """The cardinality should be a list of the same length as `num_static_categorical_features`"""				)
                UpperCAmelCase	    =			cardinality
         else:
                UpperCAmelCase	    =			[0]
         if embedding_dimension and num_static_categorical_features > 0:
                if len(snake_case__				) != num_static_categorical_features:
                       raise ValueError(
                           """The embedding dimension should be a list of the same length as `num_static_categorical_features`"""				)
                UpperCAmelCase	    =			embedding_dimension
         else:
                UpperCAmelCase	    =			[min(50 ,		(cat + 1) // 2				) for cat in self.cardinality]
         UpperCAmelCase	    =			num_parallel_samples

         # Transformer architecture configuration
         UpperCAmelCase	    =			input_size * len(snake_case__				) + self._number_of_features
         UpperCAmelCase	    =			d_model
         UpperCAmelCase	    =			encoder_attention_heads
         UpperCAmelCase	    =			decoder_attention_heads
         UpperCAmelCase	    =			encoder_ffn_dim
         UpperCAmelCase	    =			decoder_ffn_dim
         UpperCAmelCase	    =			encoder_layers
         UpperCAmelCase	    =			decoder_layers

         UpperCAmelCase	    =			dropout
         UpperCAmelCase	    =			attention_dropout
         UpperCAmelCase	    =			activation_dropout
         UpperCAmelCase	    =			encoder_layerdrop
         UpperCAmelCase	    =			decoder_layerdrop

         UpperCAmelCase	    =			activation_function
         UpperCAmelCase	    =			init_std

         UpperCAmelCase	    =			use_cache

         super().__init__(is_encoder_decoder=snake_case__ ,		**snake_case__				)



  @property
  def 		UpperCamelCase_				(      self				)			->			int:



         """simple docstring"""





         return (
             sum(self.embedding_dimension				)
             + self.num_dynamic_real_features
             + self.num_time_features
             + self.num_static_real_features
             + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
         )
