






from __future__ import annotations





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





def 		__UpperCAmelCase     (	a_				,	a_				,	a_				,	a_):
							snake_case_           =				len(a_)
							# Final check point.
							if i == j == (size - 1):
														snake_case_           =				1
														return True

							snake_case_           =				(not i < 0) and (not j < 0)  # Check lower bounds
							snake_case_           =				(i < size) and (j < size)  # Check upper bounds

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

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

																					snake_case_           =				0
																					return False
							return False


if __name__ == "__main__":
	import doctest

	doctest.testmod()













def 		__UpperCAmelCase     (	a_ = 10**9):
							snake_case_           =				1
							snake_case_           =				2

							snake_case_           =				0
							snake_case_           =				0
							snake_case_           =				0
							while perimeter <= max_perimeter:
														perimeters_sum += perimeter

														prev_value += 2 * value
														value += prev_value

														snake_case_           =				2 * value + 2 if i % 2 == 0 else 2 * value - 2
														i += 1

							return perimeters_sum


if __name__ == "__main__":
	print(f'{solution() = }')





