


from __future__ import annotations

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

UpperCamelCase														=      TypeVar("""T""")






class     _lowerCamelCase					(   Generic[T]     ):




       """simple docstring"""
       snake_case    =       42  # Cache store of keys
       snake_case    =       42  # References of the keys in cache
       snake_case    =       10  # Maximum capacity of cache



       def __init__( self							,			_SCREAMING_SNAKE_CASE						)->Optional[int]:




         '''simple docstring'''





         A_ :							Optional[int]							=   deque()
         A_ :							Optional[Any]							=   set()
         if not n:
           A_ :							Tuple							=   sys.maxsize
         elif n < 0:
           raise ValueError('''n should be an integer greater than 0.'''						)
         else:
           A_ :							List[Any]							=   n



       def 			_snake_case			( self							,			_SCREAMING_SNAKE_CASE						)->Optional[Any]:




         '''simple docstring'''





         if x not in self.key_reference:
           if len(self.dq_store						) == LRUCache._MAX_CAPACITY:
             A_ :							Dict							=   self.dq_store.pop()
             self.key_reference.remove(lowerCamelCase_						)
         else:
           self.dq_store.remove(lowerCamelCase_						)

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



       def 			_snake_case			( self						)->Any:




         '''simple docstring'''





         for k in self.dq_store:
           print(lowerCamelCase_						)







       def __repr__( self						)->Optional[int]:




         '''simple docstring'''





         return F'''LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store						)}'''


if __name__ == "__main__":
     import doctest

     doctest.testmod()

     UpperCamelCase														=      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]"











__UpperCamelCase:	str = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

__UpperCamelCase:	Tuple = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}


def       SCREAMING_SNAKE_CASE__  (       _lowercase     : dict[int, list[int]]   ,    _lowercase     : int   ,    _lowercase     : list[bool]			)   ->							list[int]:




		'''simple docstring'''
		lowercase__					:      str      =		True
		lowercase__					:      int      =		[]

		for neighbour in graph[vert]:
				if not visited[neighbour]:
						order += topology_sort(_lowercase   ,    _lowercase   ,    _lowercase			)

		order.append(_lowercase			)

		return order


def       SCREAMING_SNAKE_CASE__  (       _lowercase     : dict[int, list[int]]   ,    _lowercase     : int   ,    _lowercase     : list[bool]			)   ->							list[int]:




		'''simple docstring'''
		lowercase__					:      Union[str, Any]      =		True
		lowercase__					:      Optional[Any]      =		[vert]

		for neighbour in reversed_graph[vert]:
				if not visited[neighbour]:
						component += find_components(_lowercase   ,    _lowercase   ,    _lowercase			)

		return component





def       SCREAMING_SNAKE_CASE__  (       _lowercase     : dict[int, list[int]]			)   ->							list[list[int]]:




		'''simple docstring'''
		lowercase__					:      Optional[int]      =		len(_lowercase			) * [False]
		lowercase__					:      dict[int, list[int]]      =		{vert: [] for vert in range(len(_lowercase			)			)}

		for vert, neighbours in graph.items():
				for neighbour in neighbours:
						reversed_graph[neighbour].append(_lowercase			)

		lowercase__					:      Dict      =		[]
		for i, was_visited in enumerate(_lowercase			):
				if not was_visited:
						order += topology_sort(_lowercase   ,    _lowercase   ,    _lowercase			)

		lowercase__					:      Dict      =		[]
		lowercase__					:      Optional[Any]      =		len(_lowercase			) * [False]

		for i in range(len(_lowercase			)			):
				lowercase__					:      List[Any]      =		order[len(_lowercase			) - i - 1]
				if not visited[vert]:
						lowercase__					:      Tuple      =		find_components(_lowercase   ,    _lowercase   ,    _lowercase			)
						components_list.append(_lowercase			)

		return components_list


