



import os






def      _A				(UpperCamelCase		:      Optional[Any] )  ->Dict:



			'''simple docstring'''







			lowerCamelCase__ :      Union[str, Any]								=		len(grid[0] )
			lowerCamelCase__ :      Optional[Any]								=		len(UpperCamelCase )

			lowerCamelCase__ :      List[Any]								=		0
			lowerCamelCase__ :      Optional[Any]								=		0
			lowerCamelCase__ :      str								=		0

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

									lowerCamelCase__ :      Dict								=		max(
									    UpperCamelCase      ,			UpperCamelCase      ,			UpperCamelCase      ,			UpperCamelCase )
									if max_product > largest:
												lowerCamelCase__ :      Tuple								=		max_product

			return largest






def      _A				()  ->Optional[Any]:



			'''simple docstring'''







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

			lowerCamelCase__ :      Any								=		[[int(UpperCamelCase ) for i in grid[j]] for j in range(len(UpperCamelCase ) )]

			return largest_product(UpperCamelCase )


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








def      _A				(UpperCamelCase		:      List[Any]      ,			UpperCamelCase		:      Dict )  ->List[str]:



			'''simple docstring'''







			lowerCamelCase__ :      int								=		[1]
			for i in range(2      ,			UpperCamelCase ):
						factorials.append(factorials[-1] * i )
			assert 0 <= k < factorials[-1] * n, "k out of bounds"

			lowerCamelCase__ :      Union[str, Any]								=		[]
			lowerCamelCase__ :      Optional[Any]								=		list(range(UpperCamelCase ) )

			# Find permutation
			while factorials:
						lowerCamelCase__ :      Union[str, Any]								=		factorials.pop()
						lowerCamelCase__							,lowerCamelCase__ :      Union[str, Any]								=		divmod(UpperCamelCase      ,			UpperCamelCase )
						permutation.append(elements[number] )
						elements.remove(elements[number] )
			permutation.append(elements[0] )

			return permutation


if __name__ == "__main__":
				import doctest

				doctest.testmod()



