
"""simple docstring"""

import sys
from collections import defaultdict
class   _UpperCAmelCase				:




      def __init__(				self				)    ->       List[str]:
          UpperCAmelCase          =       []




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




      def      a_   (				self ,							lowercase_ ,							lowercase_				)    ->       Tuple:
          UpperCAmelCase          =       pos




      def      a_   (				self ,							lowercase_ ,							lowercase_ ,							lowercase_ ,							lowercase_				)    ->       Optional[int]:
          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] ,							lowercase_				)

                  self.top_to_bottom(lowercase_ ,							lowercase_ ,							lowercase_ ,							lowercase_				)




      def      a_   (				self ,							lowercase_ ,							lowercase_ ,							lowercase_ ,							lowercase_				)    ->       List[str]:
          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] ,							lowercase_				)
              else:
                  UpperCAmelCase          =       val
                  UpperCAmelCase          =       temp
                  self.set_position(lowercase_ ,							lowercase_				)
                  break
              UpperCAmelCase          =       parent
          else:
              UpperCAmelCase          =       val
              UpperCAmelCase          =       temp
              self.set_position(lowercase_ ,							0				)




      def      a_   (				self ,							lowercase_ ,							lowercase_				)    ->       Optional[Any]:
          UpperCAmelCase          =       len(lowercase_				) // 2 - 1
          for i in range(lowercase_ ,							-1 ,							-1				):
              self.top_to_bottom(lowercase_ ,							lowercase_ ,							len(lowercase_				) ,							lowercase_				)




      def      a_   (				self ,							lowercase_ ,							lowercase_				)    ->       Union[str, Any]:
          UpperCAmelCase          =       positions[0]
          UpperCAmelCase          =       sys.maxsize
          self.top_to_bottom(lowercase_ ,							0 ,							len(lowercase_				) ,							lowercase_				)
          return temp




def      lowercase__    (       lowerCAmelCase					:       Tuple			)			->   Optional[int]:






    """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 --------- >
   SCREAMING_SNAKE_CASE_            =    int(input('''Enter number of edges: ''').strip())
   SCREAMING_SNAKE_CASE_            =    defaultdict(list)
   for _ in range(edges_number):
      SCREAMING_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))





"""simple docstring"""

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding
class   _UpperCAmelCase				(		SCREAMING_SNAKE_CASE_				):
      __SCREAMING_SNAKE_CASE :				List[Any]				   =						["image_processor", "tokenizer"]
      __SCREAMING_SNAKE_CASE :				Dict				   =						"AutoImageProcessor"
      __SCREAMING_SNAKE_CASE :				Optional[int]				   =						"AutoTokenizer"




      def __init__(				self ,							lowercase_ ,							lowercase_				)    ->       List[str]:
          super().__init__(lowercase_ ,							lowercase_				)
          UpperCAmelCase          =       self.image_processor




      def __call__(				self ,							lowercase_=None ,							lowercase_=None ,							lowercase_=None ,							**lowercase_				)    ->       Any:

          if text is None and images is None:
              raise ValueError('You have to specify either text or images. Both cannot be none.'				)

          if text is not None:
              UpperCAmelCase          =       self.tokenizer(lowercase_ ,							return_tensors=lowercase_ ,							**lowercase_				)

          if images is not None:
              UpperCAmelCase          =       self.image_processor(lowercase_ ,							return_tensors=lowercase_ ,							**lowercase_				)

          if text is not None and images is not None:
              UpperCAmelCase          =       image_features.pixel_values
              return encoding
          elif text is not None:
              return encoding
          else:
              return BatchEncoding(data=dict(**lowercase_				) ,							tensor_type=lowercase_				)




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       Optional[Any]:
          return self.tokenizer.batch_decode(*lowercase_ ,							**lowercase_				)




      def      a_   (				self ,							*lowercase_ ,							**lowercase_				)    ->       Optional[int]:
          return self.tokenizer.decode(*lowercase_ ,							**lowercase_				)




      @property
      def      a_   (				self				)    ->       Optional[int]:
          return ["input_ids", "attention_mask", "pixel_values"]



