




"""simple docstring"""







def 						snake_case__       (					_lowerCamelCase				)			->Union[str, Any]:






		"""simple docstring"""


		__lowercase				:		str												=				[]
		__lowercase				:		List[str]												=				[]
		__lowercase				:		Union[str, Any]												=				{
		    "^": 3,
		    "*": 2,
		    "/": 2,
		    "%": 2,
		    "+": 1,
		    "-": 1,
		}  # Priority of each operator
		__lowercase				:		Tuple												=				len(_lowerCamelCase				) if (len(_lowerCamelCase				) > 7) else 7

		# Print table header for output
		print(
		    "Symbol".center(8				),  "Stack".center(_lowerCamelCase				),  "Postfix".center(_lowerCamelCase				),  sep=" | ",  )
		print("-" * (print_width * 3 + 7)				)

		for x in infix:
				if x.isalpha() or x.isdigit():
						post_fix.append(_lowerCamelCase				)  # if x is Alphabet / Digit, add it to Postfix
				elif x == "(":
						stack.append(_lowerCamelCase				)  # if x is "(" push to Stack
				elif x == ")":  # if x is ")" pop stack until "(" is encountered
						while stack[-1] != "(":
								post_fix.append(stack.pop()				)  # Pop stack & add the content to Postfix
						stack.pop()
				else:
						if len(_lowerCamelCase				) == 0:
								stack.append(_lowerCamelCase				)  # If stack is empty, push x to stack
						else:  # while priority of x is not > priority of element in the stack
								while len(_lowerCamelCase				) > 0 and priority[x] <= priority[stack[-1]]:
										post_fix.append(stack.pop()				)  # pop stack & add to Postfix
								stack.append(_lowerCamelCase				)  # push x to stack

				print(
				    x.center(8				),  ("".join(_lowerCamelCase				)).ljust(_lowerCamelCase				),  ("".join(_lowerCamelCase				)).ljust(_lowerCamelCase				),  sep=" | ",  )  # Output in tabular format

		while len(_lowerCamelCase				) > 0:  # while stack is not empty
				post_fix.append(stack.pop()				)  # pop stack & add to Postfix
				print(
				    " ".center(8				),  ("".join(_lowerCamelCase				)).ljust(_lowerCamelCase				),  ("".join(_lowerCamelCase				)).ljust(_lowerCamelCase				),  sep=" | ",  )  # Output in tabular format

		return "".join(_lowerCamelCase				)  # return Postfix as str

def 						snake_case__       (					_lowerCamelCase				)			->Union[str, Any]:






		"""simple docstring"""


		__lowercase				:		Union[str, Any]												=				list(infix[::-1]				)  # reverse the infix equation

		for i in range(len(_lowerCamelCase				)				):
				if infix[i] == "(":
						__lowercase				:		Optional[Any]												=				")"  # change "(" to ")"
				elif infix[i] == ")":
						__lowercase				:		str												=				"("  # change ")" to "("

		return (infix_2_postfix("".join(_lowerCamelCase				)				))[
		    ::-1
		]  # call infix_2_postfix on Infix, return reverse of Postfix


if __name__ == "__main__":
						__A   :  str					=      input('\nEnter an Infix Equation = ')  # Input an Infix equation
						__A   :  List[Any]					=      ''.join(Infix.split())  # Remove spaces from the input
						print('\n\t', Infix, '(Infix) -> ', infix_2_prefix(Infix), '(Prefix)')






"""simple docstring"""







from __future__ import annotations

import math

def 						snake_case__       (					_lowerCamelCase,  _lowerCamelCase				)			->list:






		"""simple docstring"""


		if len(_lowerCamelCase				) != 2 or len(a[0]				) != 2 or len(_lowerCamelCase				) != 2 or len(b[0]				) != 2:
				raise Exception("Matrices are not 2x2"				)
		__lowercase				:		Tuple												=				[
		    [a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],
		    [a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]],
		]
		return new_matrix

def 						snake_case__       (					_lowerCamelCase,  _lowerCamelCase				)			->Dict:






		"""simple docstring"""


		return [
		    [matrix_a[row][col] + matrix_b[row][col] for col in range(len(matrix_a[row]				)				)]
		    for row in range(len(_lowerCamelCase				)				)
		]

def 						snake_case__       (					_lowerCamelCase,  _lowerCamelCase				)			->Tuple:






		"""simple docstring"""


		return [
		    [matrix_a[row][col] - matrix_b[row][col] for col in range(len(matrix_a[row]				)				)]
		    for row in range(len(_lowerCamelCase				)				)
		]

def 						snake_case__       (					_lowerCamelCase				)			->tuple[list, list, list, list]:






		"""simple docstring"""


		if len(_lowerCamelCase				) % 2 != 0 or len(a[0]				) % 2 != 0:
				raise Exception("Odd matrices are not supported!"				)

		__lowercase				:		Tuple												=				len(_lowerCamelCase				)
		__lowercase				:		Any												=				matrix_length // 2

		__lowercase				:		Dict												=				[[a[i][j] for j in range(_lowerCamelCase,  _lowerCamelCase				)] for i in range(_lowerCamelCase				)]
		__lowercase				:		List[str]												=				[
		    [a[i][j] for j in range(_lowerCamelCase,  _lowerCamelCase				)] for i in range(_lowerCamelCase,  _lowerCamelCase				)
		]

		__lowercase				:		Union[str, Any]												=				[[a[i][j] for j in range(_lowerCamelCase				)] for i in range(_lowerCamelCase				)]
		__lowercase				:		List[str]												=				[[a[i][j] for j in range(_lowerCamelCase				)] for i in range(_lowerCamelCase,  _lowerCamelCase				)]

		return top_left, top_right, bot_left, bot_right

def 						snake_case__       (					_lowerCamelCase				)			->tuple[int, int]:






		"""simple docstring"""


		return len(_lowerCamelCase				), len(matrix[0]				)

def 						snake_case__       (					_lowerCamelCase				)			->None:






		"""simple docstring"""


		print("\n".join(str(_lowerCamelCase				) for line in matrix				)				)

def 						snake_case__       (					_lowerCamelCase,  _lowerCamelCase				)			->list:






		"""simple docstring"""


		if matrix_dimensions(_lowerCamelCase				) == (2, 2):
				return default_matrix_multiplication(_lowerCamelCase,  _lowerCamelCase				)

		__lowercase						,__lowercase						,__lowercase						,__lowercase				:		Optional[Any]												=				split_matrix(_lowerCamelCase				)
		__lowercase						,__lowercase						,__lowercase						,__lowercase				:		Any												=				split_matrix(_lowerCamelCase				)

		__lowercase				:		str												=				actual_strassen(_lowerCamelCase,  matrix_subtraction(_lowerCamelCase,  _lowerCamelCase				)				)
		__lowercase				:		Dict												=				actual_strassen(matrix_addition(_lowerCamelCase,  _lowerCamelCase				),  _lowerCamelCase				)
		__lowercase				:		Union[str, Any]												=				actual_strassen(matrix_addition(_lowerCamelCase,  _lowerCamelCase				),  _lowerCamelCase				)
		__lowercase				:		Any												=				actual_strassen(_lowerCamelCase,  matrix_subtraction(_lowerCamelCase,  _lowerCamelCase				)				)
		__lowercase				:		List[Any]												=				actual_strassen(matrix_addition(_lowerCamelCase,  _lowerCamelCase				),  matrix_addition(_lowerCamelCase,  _lowerCamelCase				)				)
		__lowercase				:		Optional[int]												=				actual_strassen(matrix_subtraction(_lowerCamelCase,  _lowerCamelCase				),  matrix_addition(_lowerCamelCase,  _lowerCamelCase				)				)
		__lowercase				:		Optional[Any]												=				actual_strassen(matrix_subtraction(_lowerCamelCase,  _lowerCamelCase				),  matrix_addition(_lowerCamelCase,  _lowerCamelCase				)				)

		__lowercase				:		str												=				matrix_addition(matrix_subtraction(matrix_addition(_lowerCamelCase,  _lowerCamelCase				),  _lowerCamelCase				),  _lowerCamelCase				)
		__lowercase				:		Dict												=				matrix_addition(_lowerCamelCase,  _lowerCamelCase				)
		__lowercase				:		int												=				matrix_addition(_lowerCamelCase,  _lowerCamelCase				)
		__lowercase				:		Union[str, Any]												=				matrix_subtraction(matrix_subtraction(matrix_addition(_lowerCamelCase,  _lowerCamelCase				),  _lowerCamelCase				),  _lowerCamelCase				)

		# construct the new matrix from our 4 quadrants
		__lowercase				:		Optional[int]												=				[]
		for i in range(len(_lowerCamelCase				)				):
				new_matrix.append(top_left[i] + top_right[i]				)
		for i in range(len(_lowerCamelCase				)				):
				new_matrix.append(bot_left[i] + bot_right[i]				)
		return new_matrix

def 						snake_case__       (					_lowerCamelCase,  _lowerCamelCase				)			->list:






		"""simple docstring"""


		if matrix_dimensions(_lowerCamelCase				)[1] != matrix_dimensions(_lowerCamelCase				)[0]:
				__lowercase				:		int												=				(
				    "Unable to multiply these matrices, please check the dimensions.\n"
				    F'Matrix A: {matrixa}\n'
				    F'Matrix B: {matrixa}'
				)
				raise Exception(_lowerCamelCase				)
		__lowercase				:		List[Any]												=				matrix_dimensions(_lowerCamelCase				)
		__lowercase				:		Tuple												=				matrix_dimensions(_lowerCamelCase				)

		if dimensiona[0] == dimensiona[1] and dimensiona[0] == dimensiona[1]:
				return [matrixa, matrixa]

		__lowercase				:		int												=				max(*_lowerCamelCase,  *_lowerCamelCase				)
		__lowercase				:		Any												=				int(math.pow(2,  math.ceil(math.loga(_lowerCamelCase				)				)				)				)
		__lowercase				:		Dict												=				matrixa
		__lowercase				:		str												=				matrixa

		# Adding zeros to the matrices so that the arrays dimensions are the same and also
		# power of 2
		for i in range(0,  _lowerCamelCase				):
				if i < dimensiona[0]:
						for _ in range(dimensiona[1],  _lowerCamelCase				):
								new_matrixa[i].append(0				)
				else:
						new_matrixa.append([0] * maxim				)
				if i < dimensiona[0]:
						for _ in range(dimensiona[1],  _lowerCamelCase				):
								new_matrixa[i].append(0				)
				else:
						new_matrixa.append([0] * maxim				)

		__lowercase				:		Dict												=				actual_strassen(_lowerCamelCase,  _lowerCamelCase				)

		# Removing the additional zeros
		for i in range(0,  _lowerCamelCase				):
				if i < dimensiona[0]:
						for _ in range(dimensiona[1],  _lowerCamelCase				):
								final_matrix[i].pop()
				else:
						final_matrix.pop()
		return final_matrix


if __name__ == "__main__":
						__A   :  int					=      [
						    [2, 3, 4, 5],
						    [6, 4, 3, 1],
						    [2, 3, 6, 7],
						    [3, 1, 2, 4],
						    [2, 3, 4, 5],
						    [6, 4, 3, 1],
						    [2, 3, 6, 7],
						    [3, 1, 2, 4],
						    [2, 3, 4, 5],
						    [6, 2, 3, 1],
						]
						__A   :  Union[str, Any]					=      [[0, 2, 1, 1], [1_6, 2, 3, 3], [2, 2, 7, 7], [1_3, 1_1, 2_2, 4]]
						print(strassen(matrixa, matrixa))
