


import os







def     lowerCAmelCase_					( __lowerCamelCase     ):
							__snake_case		:      Union[str, Any]										=       len(grid[0]     )
							__snake_case		:      Tuple										=       len(lowerCamelCase__     )

							__snake_case		:      Union[str, Any]										=       0
							__snake_case		:      int										=       0
							__snake_case		:      Optional[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		:      str										=       grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
																					__snake_case		:      List[Any]										=       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		:      int										=       (
																												    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		:      List[Any]										=       (
																												    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		:      Tuple										=       max_product

							return largest







def     lowerCAmelCase_					( ):
							__snake_case		:      List[Any]										=       []
							with open(os.path.dirname(lowerCamelCase__     ) + "/grid.txt"     ) as file:
														for line in file:
																					grid.append(line.strip("\n"     ).split(" "     )     )

							__snake_case		:      Dict										=       [[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=_lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							int					  =  ["speech"]

							def __init__(							self	:  List[Any]   ,     *lowerCamelCase	:  List[Any]   ,     **lowerCamelCase	:  Optional[Any]    )     ->   Dict:
														requires_backends(self   ,     ["speech"]    )

class     a		(metaclass=_lowerCAmelCase				):




							"""simple docstring"""


							__UpperCAmelCase   :							Optional[Any]					  =  ["speech"]

							def __init__(							self	:  int   ,     *lowerCamelCase	:  List[Any]   ,     **lowerCamelCase	:  List[Any]    )     ->   Optional[int]:
														requires_backends(self   ,     ["speech"]    )

