

from __future__ import annotations

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

lowerCamelCase           =					TypeVar('''T''')







class 						__magic_name__			(							Generic[T]							):

   '''simple docstring'''




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



   def __init__(				self,    lowercase_       )							->    None:






     """simple docstring"""






     a__  =deque()
     a__  =set()
     if not n:
       a__  =sys.maxsize
     elif n < 0:
       raise ValueError('''n should be an integer greater than 0.'''       )
     else:
       a__  =n



   def  _UpperCAmelCase (				self,    lowercase_       )							->    None:






     """simple docstring"""






     if x not in self.key_reference:
       if len(self.dq_store       ) == LRUCache._MAX_CAPACITY:
         a__  =self.dq_store.pop()
         self.key_reference.remove(lowercase_       )
     else:
       self.dq_store.remove(lowercase_       )

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



   def  _UpperCAmelCase (				self       )							->    None:






     """simple docstring"""






     for k in self.dq_store:
       print(lowercase_       )



   def __repr__(				self       )							->    str:






     """simple docstring"""






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



import os




def 			UpperCAmelCase__				(			_A      : Any							):





  '''simple docstring'''







  a__  =len(grid[0]							)
  a__  =len(_A							)

  a__  =0
  a__  =0
  a__  =0

  # Check vertically, horizontally, diagonally at the same time (only works
  # for nxn grid)
  for i in range(_A							):
    for j in range(n_rows - 3							):
      a__  =grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
      a__  =grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

      # Left-to-right diagonal (\) product
      if i < n_columns - 3:
        a__  =(
            grid[i][j]
            * grid[i + 1][j + 1]
            * grid[i + 2][j + 2]
            * grid[i + 3][j + 3]
        )

      # Right-to-left diagonal(/) product
      if i > 2:
        a__  =(
            grid[i][j]
            * grid[i - 1][j + 1]
            * grid[i - 2][j + 2]
            * grid[i - 3][j + 3]
        )

      a__  =max(
          _A	,      _A	,      _A	,      _A							)
      if max_product > largest:
        a__  =max_product

  return largest




def 			UpperCAmelCase__				(			):





  '''simple docstring'''







  a__  =[]
  with open(os.path.dirname(_A							) + '''/grid.txt'''							) as file:
    for line in file:
      grid.append(line.strip('''\n'''							).split(''' '''							)							)

  a__  =[[int(_A							) for i in grid[j]] for j in range(len(_A							)							)]

  return largest_product(_A							)


if __name__ == "__main__":
       print(solution())
