

from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

lowerCAmelCase_       	=	TypeVar('''T''')





class 	snake_case_   (		Generic[T]					):







			'''simple docstring'''

			SCREAMING_SNAKE_CASE     :   deque[T]  # Cache store of keys
			SCREAMING_SNAKE_CASE     :   set[T]  # References of the keys in cache
			SCREAMING_SNAKE_CASE     :   int									=				10  # Maximum capacity of cache







			def __init__(     self :				Dict							,   _UpperCamelCase :				int							)      ->None:
									snake_case_   =	deque()
									snake_case_   =	set()
									if not n:
															snake_case_   =	sys.maxsize
									elif n < 0:
															raise ValueError('''n should be an integer greater than 0.'''							)
									else:
															snake_case_   =	n







			def 				snake_case__(     self :				Dict							,   _UpperCamelCase :				T							)      ->None:
									if x not in self.key_reference:
															if len(self.dq_store							) == LRUCache._MAX_CAPACITY:
																					snake_case_   =	self.dq_store.pop()
																					self.key_reference.remove(_UpperCamelCase							)
									else:
															self.dq_store.remove(_UpperCamelCase							)

									self.dq_store.appendleft(_UpperCamelCase							)
									self.key_reference.add(_UpperCamelCase							)







			def 				snake_case__(     self :				List[Any]							)      ->None:
									for k in self.dq_store:
															print(_UpperCamelCase							)







			def __repr__(     self :				Optional[Any]							)      ->str:
									return f'''LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store							)}'''


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					lowerCAmelCase_       	=	LRUCache(4)
					lru_cache.refer('''A''')
					lru_cache.refer(2)
					lru_cache.refer(3)
					lru_cache.refer('''A''')
					lru_cache.refer(4)
					lru_cache.refer(5)
					lru_cache.display()

					print(lru_cache)
					assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"


from __future__ import annotations


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


def   __SCREAMING_SNAKE_CASE					(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       ):
						snake_case_   =	len(SCREAMING_SNAKE_CASE__       )
						# 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(SCREAMING_SNAKE_CASE__  ,		i + 1  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )
																		    or run_maze(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		j + 1  ,		SCREAMING_SNAKE_CASE__       )
																		    or run_maze(SCREAMING_SNAKE_CASE__  ,		i - 1  ,		SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__       )
																		    or run_maze(SCREAMING_SNAKE_CASE__  ,		SCREAMING_SNAKE_CASE__  ,		j - 1  ,		SCREAMING_SNAKE_CASE__       )
																		):
																								return True

																		snake_case_   =	0
																		return False
						return False


if __name__ == "__main__":
					import doctest

					doctest.testmod()