





"""simple docstring"""






import math




class 			__lowercase     :







					'''simple docstring'''




					def __init__(  self		,     _UpperCAmelCase=0       ):  # a graph with Node 0,1,...,N-1
									__a	:  Tuple         =					n
									__a	:  Tuple         =					[
									    [math.inf for j in range(0		,     _UpperCAmelCase       )] for i in range(0		,     _UpperCAmelCase       )
									]  # adjacency matrix for weight
									__a	:  Union[str, Any]         =					[
									    [math.inf for j in range(0		,     _UpperCAmelCase       )] for i in range(0		,     _UpperCAmelCase       )
									]  # dp[i][j] stores minimum distance from i to j







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase		,     _UpperCAmelCase		,     _UpperCAmelCase       ):
									__a	:  int         =					w







					def 	_lowerCamelCase						(  self       ):
									for k in range(0		,     self.n       ):
													for i in range(0		,     self.n       ):
																	for j in range(0		,     self.n       ):
																					__a	:  List[Any]         =					min(self.dp[i][j]		,     self.dp[i][k] + self.dp[k][j]       )







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase		,     _UpperCAmelCase       ):
									return self.dp[u][v]


if __name__ == "__main__":
		A	     =					Graph(5)
		graph.add_edge(0, 2, 9)
		graph.add_edge(0, 4, 10)
		graph.add_edge(1, 3, 5)
		graph.add_edge(2, 3, 7)
		graph.add_edge(3, 0, 10)
		graph.add_edge(3, 1, 2)
		graph.add_edge(3, 2, 1)
		graph.add_edge(3, 4, 6)
		graph.add_edge(4, 1, 3)
		graph.add_edge(4, 2, 4)
		graph.add_edge(4, 3, 9)
		graph.floyd_warshall()
		graph.show_min(1, 4)
		graph.show_min(0, 3)






"""simple docstring"""






from __future__ import annotations

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

A	     =					TypeVar('''T''')




class 			__lowercase     (     Generic[T]							):







					'''simple docstring'''




					__lowerCAmelCase					=					42  # Cache store of keys
					__lowerCAmelCase					=					42  # References of the keys in cache
					__lowerCAmelCase					=					10  # Maximum capacity of cache







					def __init__(  self		,     _UpperCAmelCase       ):
									__a	:  Optional[int]         =					deque()
									__a	:  Dict         =					set()
									if not n:
													__a	:  List[Any]         =					sys.maxsize
									elif n < 0:
													raise ValueError('''n should be an integer greater than 0.'''       )
									else:
													__a	:  str         =					n







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase       ):
									if x not in self.key_reference:
													if len(self.dq_store       ) == LRUCache._MAX_CAPACITY:
																	__a	:  int         =					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 	_lowerCamelCase						(  self       ):
									for k in self.dq_store:
													print(_UpperCAmelCase       )







					def __repr__(  self       ):
									return f"""LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store       )}"""


if __name__ == "__main__":
		import doctest

		doctest.testmod()

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