


"""simple docstring"""
import os







def 						_a				(      _SCREAMING_SNAKE_CASE				)    ->				List[str]:
							snake_case_           =		len(grid[0]				)
							snake_case_           =		len(_SCREAMING_SNAKE_CASE				)

							snake_case_           =		0
							snake_case_           =		0
							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				):
																					snake_case_           =		grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
																					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:
																												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:
																												snake_case_           =		(
																												    grid[i][j]
																												    * grid[i - 1][j + 1]
																												    * grid[i - 2][j + 2]
																												    * grid[i - 3][j + 3]
																												)

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

							return largest







def 						_a				(      )    ->				Optional[Any]:
							snake_case_           =		[]
							with open(os.path.dirname(_SCREAMING_SNAKE_CASE				) + """/grid.txt"""				) as file:
														for line in file:
																					grid.append(line.strip("""\n"""				).split(""" """				)				)

							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())







"""simple docstring"""
from math import factorial







def 						_a				(      _SCREAMING_SNAKE_CASE = 20				)    ->				int:
							snake_case_           =		2 * n  # middle entry of odd rows starting at row 3 is the solution for n = 1,
							# 2, 3,...
							snake_case_           =		n // 2

							return int(factorial(_SCREAMING_SNAKE_CASE				) / (factorial(_SCREAMING_SNAKE_CASE				) * factorial(n - k				))				)


if __name__ == "__main__":
				import sys

				if len(sys.argv) == 1:
								print(solution(20))
				else:
								try:
												__SCREAMING_SNAKE_CASE							:    Optional[int]		=    int(sys.argv[1])
												print(solution(n))
								except ValueError:
												print('Invalid entry - please enter a number.')



