





"""simple docstring"""






from __future__ import annotations

A	     =					list[list[int]]

# assigning initial values to the grid
A	     =					[
    [3, 0, 6, 5, 0, 8, 4, 0, 0],
    [5, 2, 0, 0, 0, 0, 0, 0, 0],
    [0, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]

# a grid with no solution
A	     =					[
    [5, 0, 6, 5, 0, 8, 4, 0, 3],
    [5, 2, 0, 0, 0, 0, 0, 0, 2],
    [1, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]

def       __A (     a_  :Matrix				,    a_  :int				,    a_  :int				,    a_  :int)						->						bool:
				for i in range(9):
								if grid[row][i] == n or grid[i][column] == n:
												return False

				for i in range(3):
								for j in range(3):
												if grid[(row - row % 3) + i][(column - column % 3) + j] == n:
																return False

				return True

def       __A (     a_  :Matrix)						->						tuple[int, int] | None:
				for i in range(9):
								for j in range(9):
												if grid[i][j] == 0:
																return i, j
				return None

def       __A (     a_  :Matrix)						->						Matrix | None:
				if location := find_empty_location(a_):
								__a    ,  __a	:  Optional[int]         =					location
				else:
								# If the location is ``None``, then the grid is solved.
								return grid

				for digit in range(1				,    10):
								if is_safe(a_				,    a_				,    a_				,    a_):
												__a	:  str         =					digit

												if sudoku(a_) is not None:
																return grid

												__a	:  Dict         =					0

				return None

def       __A (     a_  :Matrix)						->						None:
				for row in grid:
								for cell in row:
												print(a_				,    end=''' ''')
								print()


if __name__ == "__main__":
		# make a copy of grid so that you can compare with the unmodified grid
		for example_grid in (initial_grid, no_solution):
				print('''\nExample grid:\n''' + '''=''' * 20)
				print_solution(example_grid)
				print('''\nExample grid solution:''')
				A	     =					sudoku(example_grid)
				if solution is not None:
						print_solution(solution)
				else:
						print('''Cannot find a solution.''')






"""simple docstring"""






def       __A (     a_  :int)						->						Union[str, Any]:
				__a	:  int         =					[]
				__a	:  Dict         =					[]
				__a	:  str         =					{
				    '''^''': 3,
				    '''*''': 2,
				    '''/''': 2,
				    '''%''': 2,
				    '''+''': 1,
				    '''-''': 1,
				}  # Priority of each operator
				__a	:  Tuple         =					len(a_) if (len(a_) > 7) else 7

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

				for x in infix:
								if x.isalpha() or x.isdigit():
												post_fix.append(a_)  # if x is Alphabet / Digit, add it to Postfix
								elif x == "(":
												stack.append(a_)  # 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(a_) == 0:
																stack.append(a_)  # If stack is empty, push x to stack
												else:  # while priority of x is not > priority of element in the stack
																while len(a_) > 0 and priority[x] <= priority[stack[-1]]:
																				post_fix.append(stack.pop())  # pop stack & add to Postfix
																stack.append(a_)  # push x to stack

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

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

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

def       __A (     a_  :int)						->						List[Any]:
				__a	:  Dict         =					list(infix[::-1])  # reverse the infix equation

				for i in range(len(a_)):
								if infix[i] == "(":
												__a	:  Union[str, Any]         =					''')'''  # change "(" to ")"
								elif infix[i] == ")":
												__a	:  List[str]         =					'''('''  # change ")" to "("

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


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