





'''simple docstring'''






from __future__ import annotations







def 					_a						(       _lowerCamelCase ) ->				bool:



			"""simple docstring"""


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







def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase    ,	_lowerCamelCase    ,	_lowerCamelCase ) ->				bool:



			"""simple docstring"""


			__snake_case					:      str							      =     len(_lowerCamelCase )
			# Final check point.
			if i == j == (size - 1):
						__snake_case					:      Tuple							      =     1
						return True

			__snake_case					:      Union[str, Any]							      =     (not i < 0) and (not j < 0)  # Check lower bounds
			__snake_case					:      int							      =     (i < size) and (j < size)  # Check upper bounds

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

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

									__snake_case					:      Dict							      =     0
									return False
			return False


if __name__ == "__main__":
	import doctest

	doctest.testmod()









'''simple docstring'''






from __future__ import annotations







def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase = None    ,	_lowerCamelCase = None ) ->				None:



			"""simple docstring"""


			if start is None:
						__snake_case					:      Optional[Any]							      =     0

			if end is None:
						__snake_case					:      Optional[Any]							      =     len(_lowerCamelCase ) - 1

			if start >= end:
						return

			__snake_case					:      Tuple							      =     (start + end) // 2

			slowsort(_lowerCamelCase    ,	_lowerCamelCase    ,	_lowerCamelCase )
			slowsort(_lowerCamelCase    ,	mid + 1    ,	_lowerCamelCase )

			if sequence[end] < sequence[mid]:
						__snake_case      ,     __snake_case					:      str							      =     sequence[mid], sequence[end]

			slowsort(_lowerCamelCase    ,	_lowerCamelCase    ,	end - 1 )


if __name__ == "__main__":
	from doctest import testmod

	testmod()


