




import numpy as np





def 			lowerCAmelCase_			(  lowerCamelCase:       Tuple     ,				lowerCamelCase:       Tuple     ,				lowerCamelCase:       List[Any]						)					->			Optional[Any]:


      '''simple docstring'''




      lowerCamelCase__        =				n_draws * class_counts / class_counts.sum()
      # floored means we don't overshoot n_samples, but probably undershoot
      lowerCamelCase__        =				np.floor(lowerCamelCase						)
      # we add samples according to how much "left over" probability
      # they had, until we arrive at n_samples
      lowerCamelCase__        =				int(n_draws - floored.sum()						)
      if need_to_add > 0:
            lowerCamelCase__        =				continuous - floored
            lowerCamelCase__        =				np.sort(np.unique(lowerCamelCase						)						)[::-1]
            # add according to remainder, but break ties
            # randomly to avoid biases
            for value in values:
                  ((lowerCamelCase__		)  ,				)        =				np.where(remainder == value						)
                  # if we need_to_add less than what's in inds
                  # we draw randomly from them.
                  # if we need to add more, we add them all and
                  # go to the next value
                  lowerCamelCase__        =				min(len(lowerCamelCase						)     ,				lowerCamelCase						)
                  lowerCamelCase__        =				rng.choice(lowerCamelCase     ,				size=lowerCamelCase     ,				replace=lowerCamelCase						)
                  floored[inds] += 1
                  need_to_add -= add_now
                  if need_to_add == 0:
                        break
      return floored.astype(np.intaa						)





def 			lowerCAmelCase_			(  lowerCamelCase:       Optional[Any]     ,				lowerCamelCase:       Dict     ,				lowerCamelCase:       Any     ,				lowerCamelCase:       int     ,				lowerCamelCase:       str=10						)					->			Any:


      '''simple docstring'''




      lowerCamelCase__  ,		lowerCamelCase__        =				np.unique(lowerCamelCase     ,				return_inverse=lowerCamelCase						)
      lowerCamelCase__        =				classes.shape[0]
      lowerCamelCase__        =				np.bincount(lowerCamelCase						)
      if np.min(lowerCamelCase						) < 2:
            raise ValueError('Minimum class count error'						)
      if n_train < n_classes:
            raise ValueError(
                'The train_size = %d should be greater or ' 'equal to the number of classes = %d' % (n_train, n_classes)						)
      if n_test < n_classes:
            raise ValueError(
                'The test_size = %d should be greater or ' 'equal to the number of classes = %d' % (n_test, n_classes)						)
      lowerCamelCase__        =				np.split(np.argsort(lowerCamelCase     ,				kind='mergesort'						)     ,				np.cumsum(lowerCamelCase						)[:-1]						)
      for _ in range(lowerCamelCase						):
            lowerCamelCase__        =				approximate_mode(lowerCamelCase     ,				lowerCamelCase     ,				lowerCamelCase						)
            lowerCamelCase__        =				class_counts - n_i
            lowerCamelCase__        =				approximate_mode(lowerCamelCase     ,				lowerCamelCase     ,				lowerCamelCase						)

            lowerCamelCase__        =				[]
            lowerCamelCase__        =				[]

            for i in range(lowerCamelCase						):
                  lowerCamelCase__        =				rng.permutation(class_counts[i]						)
                  lowerCamelCase__        =				class_indices[i].take(lowerCamelCase     ,				mode='clip'						)
                  train.extend(perm_indices_class_i[: n_i[i]]						)
                  test.extend(perm_indices_class_i[n_i[i] : n_i[i] + t_i[i]]						)
            lowerCamelCase__        =				rng.permutation(lowerCamelCase						)
            lowerCamelCase__        =				rng.permutation(lowerCamelCase						)

            yield train, test





def 			lowerCAmelCase_			(  lowerCamelCase:       int     ,				lowerCamelCase:       list[tuple[int, int, int]]						)					->			list[tuple[int, int, int]]:


      '''simple docstring'''




      lowerCamelCase__        =				sorted(lowerCamelCase     ,				key=lambda lowerCamelCase						: edge[2]						)

      lowerCamelCase__        =				list(range(lowerCamelCase						)						)

      def find_parent(lowerCamelCase:       int						):
            if i != parent[i]:
                  lowerCamelCase__        =				find_parent(parent[i]						)
            return parent[i]

      lowerCamelCase__        =				0
      lowerCamelCase__        =				[]

      for edge in edges:
            lowerCamelCase__        =				find_parent(edge[0]						)
            lowerCamelCase__        =				find_parent(edge[1]						)
            if parent_a != parent_b:
                  minimum_spanning_tree_cost += edge[2]
                  minimum_spanning_tree.append(lowerCamelCase						)
                  lowerCamelCase__        =				parent_b

      return minimum_spanning_tree


if __name__ == "__main__":  # pragma: no cover
      __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    :   Tuple       =list(map(int, input().strip().split()))
      __SCREAMING_SNAKE_CASE    :   Optional[Any]       =[]

      for _ in range(num_edges):
            __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    :   Optional[int]       =(int(x) for x in input().strip().split())
            edges.append((nodea, nodea, cost))

      kruskal(num_nodes, edges)