

'''simple docstring'''

def      __magic_name__							(			A				)      ->		bool:
	# must be
	snake_case							=					[list(A				) for row in matrix]
	if matrix and isinstance(A       , A				):
		if isinstance(matrix[0]       , A				):
			snake_case							=					0
			for row in matrix:
				if prev_len == 0:
					snake_case							=					len(A				)
					snake_case							=					True
				else:
					snake_case							=					prev_len == len(A				)
		else:
			snake_case							=					True
	else:
		snake_case							=					False

	return result

def      __magic_name__							(			A				)      ->		None:
	if check_matrix(A				) and len(A				) > 0:
		snake_case							=					[list(A				) for row in a]
		snake_case							=					len(A				)
		if isinstance(a[0]       , A				):
			snake_case							=					len(a[0]				)
		else:
			for dat in a:
				print(A				)
			return

		# horizotal printing increasing
		for i in range(0       , A				):
			print(a[0][i]				)
		# vertical printing down
		for i in range(1       , A				):
			print(a[i][mat_col - 1]				)
		# horizotal printing decreasing
		if mat_row > 1:
			for i in range(mat_col - 2       , -1       , -1				):
				print(a[mat_row - 1][i]				)
        # vertical printing up
		for i in range(mat_row - 2       , 0       , -1				):
			print(a[i][0]				)
		snake_case							=					[row[1 : mat_col - 1] for row in a[1 : mat_row - 1]]
		if len(A				) > 0:
			spiral_print_clockwise(A				)
		else:
			return
	else:
		print('Not a valid matrix'				)
		return

def      __magic_name__							(			A				)      ->		list[int]:
	if matrix:
		return list(matrix.pop(0				)				) + spiral_traversal(list(zip(*A				)				)[::-1]				)
	else:
		return []


# driver code
if __name__ == "__main__":
						import doctest

						doctest.testmod()

						lowerCAmelCase_     =      [[1, 2, 3, 4], [5, 6, 7, 8], [9, 1_0, 1_1, 1_2]]
						spiral_print_clockwise(a)







'''simple docstring'''

def        SCREAMING_SNAKE_CASE_  (	snake_case_				:	int   ,     snake_case_				:	list[tuple[int, int, int]]							)       ->	list[tuple[int, int, int]]:
 SCREAMING_SNAKE_CASE  :  List[Any]								=		sorted(snake_case_   ,     key=lambda snake_case_							: edge[2]							)

 SCREAMING_SNAKE_CASE  :  str								=		list(range(snake_case_							)							)

 def find_parent(snake_case_				:	Union[str, Any]							):
  if i != parent[i]:
   SCREAMING_SNAKE_CASE  :  int								=		find_parent(parent[i]							)
  return parent[i]

 SCREAMING_SNAKE_CASE  :  Union[str, Any]								=		0
 SCREAMING_SNAKE_CASE  :  Any								=		[]

 for edge in edges:
  SCREAMING_SNAKE_CASE  :  Dict								=		find_parent(edge[0]							)
  SCREAMING_SNAKE_CASE  :  Optional[int]								=		find_parent(edge[1]							)
  if parent_a != parent_b:
   minimum_spanning_tree_cost += edge[2]
   minimum_spanning_tree.append(snake_case_							)
   SCREAMING_SNAKE_CASE  :  Tuple								=		parent_b

 return minimum_spanning_tree


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

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

   kruskal(num_nodes, edges)


