






"""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))










"""simple docstring"""






import argparse
import logging
import pickle
from collections import Counter


logging.basicConfig(
    format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO
)
UpperCAmelCase_   : Dict   			= logging.getLogger(__name__)

if __name__ == "__main__":
  UpperCAmelCase_   : List[str]   			= argparse.ArgumentParser(
      description="""Token Counts for smoothing the masking probabilities in MLM (cf XLM/word2vec)"""
  )
  parser.add_argument(
      """--data_file""", type=str, default="""data/dump.bert-base-uncased.pickle""", help="""The binarized dataset."""
  )
  parser.add_argument(
      """--token_counts_dump""", type=str, default="""data/token_counts.bert-base-uncased.pickle""", help="""The dump file."""
  )
  parser.add_argument("""--vocab_size""", default=30522, type=int)
  UpperCAmelCase_   : Optional[Any]   			= parser.parse_args()

  logger.info(f'''Loading data from {args.data_file}''')
  with open(args.data_file, """rb""") as fp:
    UpperCAmelCase_   : Union[str, Any]   			= pickle.load(fp)

  logger.info("""Counting occurrences for MLM.""")
  UpperCAmelCase_   : Any   			= Counter()
  for tk_ids in data:
    counter.update(tk_ids)
  UpperCAmelCase_   : List[Any]   			= [0] * args.vocab_size
  for k, v in counter.items():
    UpperCAmelCase_   : Dict   			= v

  logger.info(f'''Dump to {args.token_counts_dump}''')
  with open(args.token_counts_dump, """wb""") as handle:
    pickle.dump(counts, handle, protocol=pickle.HIGHEST_PROTOCOL)


