





import os



def    __lowercase   (      _SCREAMING_SNAKE_CASE	) ->   Any:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						len(grid[0]	)
      SCREAMING_SNAKE_CASE		=						len(_SCREAMING_SNAKE_CASE	)

      SCREAMING_SNAKE_CASE		=						0
      SCREAMING_SNAKE_CASE		=						0
      SCREAMING_SNAKE_CASE		=						0

      # Check vertically, horizontally, diagonally at the same time (only works
      # for nxn grid)
      for i in range(_SCREAMING_SNAKE_CASE	):
            for j in range(n_rows - 3	):
                  SCREAMING_SNAKE_CASE		=						grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
                  SCREAMING_SNAKE_CASE		=						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:
                        SCREAMING_SNAKE_CASE		=						(
                            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:
                        SCREAMING_SNAKE_CASE		=						(
                            grid[i][j]
                            * grid[i - 1][j + 1]
                            * grid[i - 2][j + 2]
                            * grid[i - 3][j + 3]
                        )

                  SCREAMING_SNAKE_CASE		=						max(
                      _SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE	)
                  if max_product > largest:
                        SCREAMING_SNAKE_CASE		=						max_product

      return largest



def    __lowercase   (      ) ->   Optional[Any]:


      '''simple docstring'''


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

      SCREAMING_SNAKE_CASE		=						[[int(_SCREAMING_SNAKE_CASE	) for i in grid[j]] for j in range(len(_SCREAMING_SNAKE_CASE	)	)]

      return largest_product(_SCREAMING_SNAKE_CASE	)


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









def    __lowercase   (      _SCREAMING_SNAKE_CASE = 10	) ->   str:


      '''simple docstring'''


      if not isinstance(_SCREAMING_SNAKE_CASE ,						_SCREAMING_SNAKE_CASE	) or n < 0:
            raise ValueError("""Invalid input"""	)
      SCREAMING_SNAKE_CASE		=						10**n
      SCREAMING_SNAKE_CASE		=						2_84_33 * (pow(2 ,						7_83_04_57 ,						_SCREAMING_SNAKE_CASE	)) + 1
      return str(number % modulus	)


if __name__ == "__main__":
      from doctest import testmod

      testmod()
      print(F'''{solution(1_0) = }''')


