


"""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			( )      ->			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"""
import math





class        __A       :





							'''simple docstring'''

							def __init__(			self							: List[str]						,    UpperCAmelCase_							: Tuple=0    )   ->Optional[int]:  # a graph with Node 0,1,...,N-1



														"""simple docstring"""



														snake_case_          =						n
														snake_case_          =						[
														    [math.inf for j in range(0						,    UpperCAmelCase_    )] for i in range(0						,    UpperCAmelCase_    )
														]  # adjacency matrix for weight
														snake_case_          =						[
														    [math.inf for j in range(0						,    UpperCAmelCase_    )] for i in range(0						,    UpperCAmelCase_    )
														]  # dp[i][j] stores minimum distance from i to j



							def 						lowerCAmelCase    (			self							: List[str]						,    UpperCAmelCase_							: Any						,    UpperCAmelCase_							: List[str]						,    UpperCAmelCase_							: Optional[Any]    )   ->Optional[int]:



														"""simple docstring"""



														snake_case_          =						w



							def 						lowerCAmelCase    (			self							: Optional[int]    )   ->Any:



														"""simple docstring"""



														for k in range(0						,    self.n    ):
																					for i in range(0						,    self.n    ):
																												for j in range(0						,    self.n    ):
																																			snake_case_          =						min(self.dp[i][j]						,    self.dp[i][k] + self.dp[k][j]    )



							def 						lowerCAmelCase    (			self							: Optional[int]						,    UpperCAmelCase_							: Dict						,    UpperCAmelCase_							: Optional[Any]    )   ->Union[str, Any]:



														"""simple docstring"""



														return self.dp[u][v]


if __name__ == "__main__":
				__SCREAMING_SNAKE_CASE							:      Optional[int]						=      Graph(5)
				graph.add_edge(0, 2, 9)
				graph.add_edge(0, 4, 10)
				graph.add_edge(1, 3, 5)
				graph.add_edge(2, 3, 7)
				graph.add_edge(3, 0, 10)
				graph.add_edge(3, 1, 2)
				graph.add_edge(3, 2, 1)
				graph.add_edge(3, 4, 6)
				graph.add_edge(4, 1, 3)
				graph.add_edge(4, 2, 4)
				graph.add_edge(4, 3, 9)
				graph.floyd_warshall()
				graph.show_min(1, 4)
				graph.show_min(0, 3)



