
import os


def 			UpperCamelCase					(    __lowerCamelCase     : Optional[int]    ):
       snake_case       :   Union[str, Any]							=      len(grid[0]    )
       snake_case       :   int							=      len(__lowerCamelCase    )

       snake_case       :   List[Any]							=      0
       snake_case       :   Dict							=      0
       snake_case       :   int							=      0

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

                     snake_case       :   Any							=      max(
                         __lowerCamelCase				,					__lowerCamelCase				,					__lowerCamelCase				,					__lowerCamelCase    )
                     if max_product > largest:
                            snake_case       :   List[str]							=      max_product

       return largest


def 			UpperCamelCase					(    ):
       snake_case       :   Optional[int]							=      []
       with open(os.path.dirname(__lowerCamelCase    ) + "/grid.txt"    ) as file:
              for line in file:
                     grid.append(line.strip("\n"    ).split(" "    )    )

       snake_case       :   Optional[int]							=      [[int(__lowerCamelCase    ) for i in grid[j]] for j in range(len(__lowerCamelCase    )    )]

       return largest_product(__lowerCamelCase    )


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









from ..utils import DummyObject, requires_backends


class        _a							(			metaclass=UpperCamelCase__			):
							_lowercase	:			Any        = ['''torch''', '''scipy''']

							def __init__(							self:	int    ,						*UpperCamelCase_:	Any    ,						**UpperCamelCase_:	Optional[Any]							)			->   List[str]:





									"""simple docstring"""







									requires_backends(self    ,						['''torch''', '''scipy''']							)

							@classmethod
							def       lowerCamelCase_ (							cls:	Optional[int]    ,						*UpperCamelCase_:	Any    ,						**UpperCamelCase_:	List[Any]							)			->   int:





									"""simple docstring"""







									requires_backends(cls    ,						['''torch''', '''scipy''']							)


							@classmethod
							def       lowerCamelCase_ (							cls:	Any    ,						*UpperCamelCase_:	Any    ,						**UpperCamelCase_:	Dict							)			->   Optional[int]:





									"""simple docstring"""







									requires_backends(cls    ,						['''torch''', '''scipy''']							)


