




import logging

# standard libraries
import sys

import numpy as np
import pytest  # type: ignore

# Custom/local libraries
from matrix import matrix_operation as matop

UpperCamelCase__						=		[[1_2, 1_0], [3, 9]]
UpperCamelCase__						=		[[3, 4], [7, 4]]
UpperCamelCase__						=		[[3, 0, 2], [2, 0, -2], [0, 1, 1]]
UpperCamelCase__						=		[[3, 0, -2], [2, 0, 2], [0, 1, 1]]
UpperCamelCase__						=		[[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
UpperCamelCase__						=		[1]
UpperCamelCase__						=		[2]

UpperCamelCase__						=		logging.getLogger()
UpperCamelCase__						=		logging.DEBUG
UpperCamelCase__						=		logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)






@pytest.mark.mat_ops
@pytest.mark.parametrize(
    ('mat1', 'mat2')		,  [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]     )
def    snake_case   (				A		,  A     )				->				List[Any]:




	'''simple docstring'''


	if (np.array(_UpperCamelCase     )).shape < (2, 2) or (np.array(_UpperCamelCase     )).shape < (2, 2):
		with pytest.raises(_UpperCamelCase     ):
			logger.info(f"\n\t{test_addition.__name__} returned integer"     )
			matop.add(_UpperCamelCase		,  _UpperCamelCase     )
	elif (np.array(_UpperCamelCase     )).shape == (np.array(_UpperCamelCase     )).shape:
		logger.info(f"\n\t{test_addition.__name__} with same matrix dims"     )
		lowerCamelCase_				:						List[str]				  =				(np.array(_UpperCamelCase     ) + np.array(_UpperCamelCase     )).tolist()
		lowerCamelCase_				:						Any				  =				matop.add(_UpperCamelCase		,  _UpperCamelCase     )
		assert theo == act
	else:
		with pytest.raises(_UpperCamelCase     ):
			logger.info(f"\n\t{test_addition.__name__} with different matrix dims"     )
			matop.add(_UpperCamelCase		,  _UpperCamelCase     )






@pytest.mark.mat_ops
@pytest.mark.parametrize(
    ('mat1', 'mat2')		,  [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]     )
def    snake_case   (				A		,  A     )				->				List[Any]:




	'''simple docstring'''


	if (np.array(_UpperCamelCase     )).shape < (2, 2) or (np.array(_UpperCamelCase     )).shape < (2, 2):
		with pytest.raises(_UpperCamelCase     ):
			logger.info(f"\n\t{test_subtraction.__name__} returned integer"     )
			matop.subtract(_UpperCamelCase		,  _UpperCamelCase     )
	elif (np.array(_UpperCamelCase     )).shape == (np.array(_UpperCamelCase     )).shape:
		logger.info(f"\n\t{test_subtraction.__name__} with same matrix dims"     )
		lowerCamelCase_				:						Tuple				  =				(np.array(_UpperCamelCase     ) - np.array(_UpperCamelCase     )).tolist()
		lowerCamelCase_				:						str				  =				matop.subtract(_UpperCamelCase		,  _UpperCamelCase     )
		assert theo == act
	else:
		with pytest.raises(_UpperCamelCase     ):
			logger.info(f"\n\t{test_subtraction.__name__} with different matrix dims"     )
			assert matop.subtract(_UpperCamelCase		,  _UpperCamelCase     )






@pytest.mark.mat_ops
@pytest.mark.parametrize(
    ('mat1', 'mat2')		,  [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]     )
def    snake_case   (				A		,  A     )				->				Union[str, Any]:




	'''simple docstring'''


	if (np.array(_UpperCamelCase     )).shape < (2, 2) or (np.array(_UpperCamelCase     )).shape < (2, 2):
		logger.info(f"\n\t{test_multiplication.__name__} returned integer"     )
		with pytest.raises(_UpperCamelCase     ):
			matop.add(_UpperCamelCase		,  _UpperCamelCase     )
	elif (np.array(_UpperCamelCase     )).shape == (np.array(_UpperCamelCase     )).shape:
		logger.info(f"\n\t{test_multiplication.__name__} meets dim requirements"     )
		lowerCamelCase_				:						Optional[int]				  =				(np.matmul(_UpperCamelCase		,  _UpperCamelCase     )).tolist()
		lowerCamelCase_				:						List[Any]				  =				matop.multiply(_UpperCamelCase		,  _UpperCamelCase     )
		assert theo == act
	else:
		with pytest.raises(_UpperCamelCase     ):
			logger.info(
			    f"\n\t{test_multiplication.__name__} does not meet dim requirements"     )
			assert matop.subtract(_UpperCamelCase		,  _UpperCamelCase     )






@pytest.mark.mat_ops
def    snake_case   (				)				->				List[str]:




	'''simple docstring'''


	lowerCamelCase_				:						Optional[Any]				  =				(3.5 * np.array(_UpperCamelCase     )).tolist()
	lowerCamelCase_				:						Union[str, Any]				  =				matop.scalar_multiply(_UpperCamelCase		,  3.5     )
	assert theo == act






@pytest.mark.mat_ops
def    snake_case   (				)				->				Optional[int]:




	'''simple docstring'''


	lowerCamelCase_				:						Optional[int]				  =				(np.identity(5     )).tolist()
	lowerCamelCase_				:						List[str]				  =				matop.identity(5     )
	assert theo == act






@pytest.mark.mat_ops
@pytest.mark.parametrize('mat'		,  [mat_a, mat_b, mat_c, mat_d, mat_e, mat_f]     )
def    snake_case   (				A     )				->				Dict:




	'''simple docstring'''


	if (np.array(_UpperCamelCase     )).shape < (2, 2):
		with pytest.raises(_UpperCamelCase     ):
			logger.info(f"\n\t{test_transpose.__name__} returned integer"     )
			matop.transpose(_UpperCamelCase     )
	else:
		lowerCamelCase_				:						Dict				  =				(np.transpose(_UpperCamelCase     )).tolist()
		lowerCamelCase_				:						Tuple				  =				matop.transpose(_UpperCamelCase		,  return_map=_UpperCamelCase     )
		assert theo == act


"""simple docstring"""







def        __lowerCAmelCase							(_UpperCamelCase			,    _UpperCamelCase						):
	__lowerCAmelCase     :		Any		     = sorted(_UpperCamelCase			,    key=lambda _UpperCamelCase						: edge[2]						)

	__lowerCAmelCase     :		Union[str, Any]		     = list(range(_UpperCamelCase						)						)

	def find_parent(_UpperCamelCase						):
		if i != parent[i]:
			__lowerCAmelCase     :		int		     = find_parent(parent[i]						)
		return parent[i]

	__lowerCAmelCase     :		Optional[Any]		     = 0
	__lowerCAmelCase     :		List[str]		     = []

	for edge in edges:
		__lowerCAmelCase     :		List[str]		     = find_parent(edge[0]						)
		__lowerCAmelCase     :		Optional[Any]		     = find_parent(edge[1]						)
		if parent_a != parent_b:
			minimum_spanning_tree_cost += edge[2]
			minimum_spanning_tree.append(_UpperCamelCase						)
			__lowerCAmelCase     :		Optional[Any]		     = parent_b

	return minimum_spanning_tree


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

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

							kruskal(num_nodes, edges)