




"""simple docstring"""




def      __UpperCAmelCase     ( __UpperCamelCase	,				__UpperCamelCase	):
			while a != 0:
						__lowercase			,__lowercase			:  Tuple								=       b % a, a
			return b







def      __UpperCAmelCase     ( __UpperCamelCase	,				__UpperCamelCase	):
			if gcd(__UpperCamelCase	,				__UpperCamelCase	) != 1:
						__lowercase			:  Union[str, Any]								=       f"""mod inverse of {a!r} and {m!r} does not exist"""
						raise ValueError(__UpperCamelCase	)
			__lowercase			,__lowercase			,__lowercase			:  str								=       1, 0, a
			__lowercase			,__lowercase			,__lowercase			:  str								=       0, 1, m
			while va != 0:
						__lowercase			:  Union[str, Any]								=       ua // va
						__lowercase			,__lowercase			,__lowercase			,__lowercase			,__lowercase			,__lowercase			:  int								=       (ua - q * va), (ua - q * va), (ua - q * va), va, va, va
			return ua % m









"""simple docstring"""






from __future__ import annotations







def 	_snake_case     (							lowercase__						):
				_lowerCamelCase	:     int       =       len(lowercase__						)
				# We need to create solution object to save path.
				_lowerCamelCase	:     Tuple       =       [[0 for _ in range(lowercase__						)] for _ in range(lowercase__						)]
				_lowerCamelCase	:     Optional[Any]       =       run_maze(lowercase__				,       0				,       0				,       lowercase__						)
				if solved:
								print('\n'.join(str(lowercase__						) for row in solutions						)						)
				else:
								print('No solution exists!'						)
				return solved







def 	_snake_case     (							lowercase__				,       lowercase__				,       lowercase__				,       lowercase__						):
				_lowerCamelCase	:     Optional[int]       =       len(lowercase__						)
				# Final check point.
				if i == j == (size - 1):
								_lowerCamelCase	:     Optional[Any]       =       1
								return True

				_lowerCamelCase	:     List[str]       =       (not i < 0) and (not j < 0)  # Check lower bounds
				_lowerCamelCase	:     List[str]       =       (i < size) and (j < size)  # Check upper bounds

				if lower_flag and upper_flag:
								# check for already visited and block points.
								_lowerCamelCase	:     List[Any]       =       (not solutions[i][j]) and (not maze[i][j])
								if block_flag:
												# check visited
												_lowerCamelCase	:     Union[str, Any]       =       1

												# check for directions
												if (
												    run_maze(lowercase__				,       i + 1				,       lowercase__				,       lowercase__						)
												    or run_maze(lowercase__				,       lowercase__				,       j + 1				,       lowercase__						)
												    or run_maze(lowercase__				,       i - 1				,       lowercase__				,       lowercase__						)
												    or run_maze(lowercase__				,       lowercase__				,       j - 1				,       lowercase__						)
												):
																return True

												_lowerCamelCase	:     Dict       =       0
												return False
				return False


if __name__ == "__main__":
			import doctest

			doctest.testmod()