
'''simple docstring'''



from collections import deque
from math import floor
from random import random
from time import time




class   UpperCAmelCase_					:






						'''simple docstring'''






						def __init__( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			{}




						def  _lowercase     ( self   ,       _lowercase   ,       _lowercase   ,       _lowercase=1				):

												"""simple docstring"""



												if self.graph.get(_lowercase				):
																		if self.graph[u].count([w, v]				) == 0:
																								self.graph[u].append([w, v]				)
												else:
																		_lowerCAmelCase  						=			[[w, v]]
												if not self.graph.get(_lowercase				):
																		_lowerCAmelCase  						=			[]




						def  _lowercase     ( self				):

												"""simple docstring"""



												return list(self.graph				)




						def  _lowercase     ( self   ,       _lowercase   ,       _lowercase				):

												"""simple docstring"""



												if self.graph.get(_lowercase				):
																		for _ in self.graph[u]:
																								if _[1] == v:
																														self.graph[u].remove(_lowercase				)




						def  _lowercase     ( self   ,       _lowercase=-2   ,       _lowercase=-1				):

												"""simple docstring"""



												if s == d:
																		return []
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			[]
												if s == -2:
																		_lowerCAmelCase  						=			list(self.graph				)[0]
												stack.append(_lowercase				)
												visited.append(_lowercase				)
												_lowerCAmelCase  						=			s

												while True:
																		# check if there is any non isolated nodes
																		if len(self.graph[s]				) != 0:
																								_lowerCAmelCase  						=			s
																								for node in self.graph[s]:
																														if visited.count(node[1]				) < 1:
																																				if node[1] == d:
																																										visited.append(_lowercase				)
																																										return visited
																																				else:
																																										stack.append(node[1]				)
																																										visited.append(node[1]				)
																																										_lowerCAmelCase  						=			node[1]
																																										break

            # check if all the children are visited
																		if s == ss:
																								stack.pop()
																								if len(_lowercase				) != 0:
																														_lowerCAmelCase  						=			stack[len(_lowercase				) - 1]
																		else:
																								_lowerCAmelCase  						=			ss

																		# check if se have reached the starting point
																		if len(_lowercase				) == 0:
																								return visited




						def  _lowercase     ( self   ,       _lowercase=-1				):

												"""simple docstring"""



												if c == -1:
																		_lowerCAmelCase  						=			floor(random() * 10_000				) + 10
												for i in range(_lowercase				):
																		# every vertex has max 100 edges
																		for _ in range(floor(random() * 102				) + 1				):
																								_lowerCAmelCase  						=			floor(random() * c				) + 1
																								if n != i:
																														self.add_pair(_lowercase   ,       _lowercase   ,       1				)




						def  _lowercase     ( self   ,       _lowercase=-2				):

												"""simple docstring"""



												_lowerCAmelCase  						=			deque()
												_lowerCAmelCase  						=			[]
												if s == -2:
																		_lowerCAmelCase  						=			list(self.graph				)[0]
												d.append(_lowercase				)
												visited.append(_lowercase				)
												while d:
																		_lowerCAmelCase  						=			d.popleft()
																		if len(self.graph[s]				) != 0:
																								for node in self.graph[s]:
																														if visited.count(node[1]				) < 1:
																																				d.append(node[1]				)
																																				visited.append(node[1]				)
												return visited




						def  _lowercase     ( self   ,       _lowercase				):

												"""simple docstring"""



												_lowerCAmelCase  						=			0
												for x in self.graph:
																		for y in self.graph[x]:
																								if y[1] == u:
																														count += 1
												return count




						def  _lowercase     ( self   ,       _lowercase				):

												"""simple docstring"""



												return len(self.graph[u]				)




						def  _lowercase     ( self   ,       _lowercase=-2				):

												"""simple docstring"""



												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			[]
												if s == -2:
																		_lowerCAmelCase  						=			list(self.graph				)[0]
												stack.append(_lowercase				)
												visited.append(_lowercase				)
												_lowerCAmelCase  						=			s
												_lowerCAmelCase  						=			[]

												while True:
																		# check if there is any non isolated nodes
																		if len(self.graph[s]				) != 0:
																								_lowerCAmelCase  						=			s
																								for node in self.graph[s]:
																														if visited.count(node[1]				) < 1:
																																				stack.append(node[1]				)
																																				visited.append(node[1]				)
																																				_lowerCAmelCase  						=			node[1]
																																				break

            # check if all the children are visited
																		if s == ss:
																								sorted_nodes.append(stack.pop()				)
																								if len(_lowercase				) != 0:
																														_lowerCAmelCase  						=			stack[len(_lowercase				) - 1]
																		else:
																								_lowerCAmelCase  						=			ss

																		# check if se have reached the starting point
																		if len(_lowercase				) == 0:
																								return sorted_nodes




						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			list(self.graph				)[0]
												stack.append(_lowercase				)
												visited.append(_lowercase				)
												_lowerCAmelCase  						=			-2
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			s
												_lowerCAmelCase  						=			False
												_lowerCAmelCase  						=			set()

												while True:
																		# check if there is any non isolated nodes
																		if len(self.graph[s]				) != 0:
																								_lowerCAmelCase  						=			s
																								for node in self.graph[s]:
																														if (
																														    visited.count(node[1]				) > 0
																														    and node[1] != parent
																														    and indirect_parents.count(node[1]				) > 0
																														    and not on_the_way_back
																														):
																																				_lowerCAmelCase  						=			len(_lowercase				) - 1
																																				while len_stack >= 0:
																																										if stack[len_stack] == node[1]:
																																																anticipating_nodes.add(node[1]				)
																																																break
																																										else:
																																																anticipating_nodes.add(stack[len_stack]				)
																																																len_stack -= 1
																														if visited.count(node[1]				) < 1:
																																				stack.append(node[1]				)
																																				visited.append(node[1]				)
																																				_lowerCAmelCase  						=			node[1]
																																				break

            # check if all the children are visited
																		if s == ss:
																								stack.pop()
																								_lowerCAmelCase  						=			True
																								if len(_lowercase				) != 0:
																														_lowerCAmelCase  						=			stack[len(_lowercase				) - 1]
																		else:
																								_lowerCAmelCase  						=			False
																								indirect_parents.append(_lowercase				)
																								_lowerCAmelCase  						=			s
																								_lowerCAmelCase  						=			ss

																		# check if se have reached the starting point
																		if len(_lowercase				) == 0:
																								return list(_lowercase				)




						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			list(self.graph				)[0]
												stack.append(_lowercase				)
												visited.append(_lowercase				)
												_lowerCAmelCase  						=			-2
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			s
												_lowerCAmelCase  						=			False
												_lowerCAmelCase  						=			set()

												while True:
																		# check if there is any non isolated nodes
																		if len(self.graph[s]				) != 0:
																								_lowerCAmelCase  						=			s
																								for node in self.graph[s]:
																														if (
																														    visited.count(node[1]				) > 0
																														    and node[1] != parent
																														    and indirect_parents.count(node[1]				) > 0
																														    and not on_the_way_back
																														):
																																				_lowerCAmelCase  						=			len(_lowercase				) - 1
																																				while len_stack_minus_one >= 0:
																																										if stack[len_stack_minus_one] == node[1]:
																																																anticipating_nodes.add(node[1]				)
																																																break
																																										else:
																																																return True
																														if visited.count(node[1]				) < 1:
																																				stack.append(node[1]				)
																																				visited.append(node[1]				)
																																				_lowerCAmelCase  						=			node[1]
																																				break

            # check if all the children are visited
																		if s == ss:
																								stack.pop()
																								_lowerCAmelCase  						=			True
																								if len(_lowercase				) != 0:
																														_lowerCAmelCase  						=			stack[len(_lowercase				) - 1]
																		else:
																								_lowerCAmelCase  						=			False
																								indirect_parents.append(_lowercase				)
																								_lowerCAmelCase  						=			s
																								_lowerCAmelCase  						=			ss

																		# check if se have reached the starting point
																		if len(_lowercase				) == 0:
																								return False




						def  _lowercase     ( self   ,       _lowercase=-2   ,       _lowercase=-1				):

												"""simple docstring"""



												_lowerCAmelCase  						=			time()
												self.dfs(_lowercase   ,       _lowercase				)
												_lowerCAmelCase  						=			time()
												return end - begin




						def  _lowercase     ( self   ,       _lowercase=-2				):

												"""simple docstring"""



												_lowerCAmelCase  						=			time()
												self.bfs(_lowercase				)
												_lowerCAmelCase  						=			time()
												return end - begin






class   UpperCAmelCase_					:






						'''simple docstring'''






						def __init__( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			{}




						def  _lowercase     ( self   ,       _lowercase   ,       _lowercase   ,       _lowercase=1				):

												"""simple docstring"""



												if self.graph.get(_lowercase				):
																		# if there already is a edge
																		if self.graph[u].count([w, v]				) == 0:
																								self.graph[u].append([w, v]				)
												else:
																		# if u does not exist
																		_lowerCAmelCase  						=			[[w, v]]
												# add the other way
												if self.graph.get(_lowercase				):
																		# if there already is a edge
																		if self.graph[v].count([w, u]				) == 0:
																								self.graph[v].append([w, u]				)
												else:
																		# if u does not exist
																		_lowerCAmelCase  						=			[[w, u]]




						def  _lowercase     ( self   ,       _lowercase   ,       _lowercase				):

												"""simple docstring"""



												if self.graph.get(_lowercase				):
																		for _ in self.graph[u]:
																								if _[1] == v:
																														self.graph[u].remove(_lowercase				)
        # the other way round
												if self.graph.get(_lowercase				):
																		for _ in self.graph[v]:
																								if _[1] == u:
																														self.graph[v].remove(_lowercase				)




						def  _lowercase     ( self   ,       _lowercase=-2   ,       _lowercase=-1				):

												"""simple docstring"""



												if s == d:
																		return []
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			[]
												if s == -2:
																		_lowerCAmelCase  						=			list(self.graph				)[0]
												stack.append(_lowercase				)
												visited.append(_lowercase				)
												_lowerCAmelCase  						=			s

												while True:
																		# check if there is any non isolated nodes
																		if len(self.graph[s]				) != 0:
																								_lowerCAmelCase  						=			s
																								for node in self.graph[s]:
																														if visited.count(node[1]				) < 1:
																																				if node[1] == d:
																																										visited.append(_lowercase				)
																																										return visited
																																				else:
																																										stack.append(node[1]				)
																																										visited.append(node[1]				)
																																										_lowerCAmelCase  						=			node[1]
																																										break

            # check if all the children are visited
																		if s == ss:
																								stack.pop()
																								if len(_lowercase				) != 0:
																														_lowerCAmelCase  						=			stack[len(_lowercase				) - 1]
																		else:
																								_lowerCAmelCase  						=			ss

																		# check if se have reached the starting point
																		if len(_lowercase				) == 0:
																								return visited




						def  _lowercase     ( self   ,       _lowercase=-1				):

												"""simple docstring"""



												if c == -1:
																		_lowerCAmelCase  						=			floor(random() * 10_000				) + 10
												for i in range(_lowercase				):
																		# every vertex has max 100 edges
																		for _ in range(floor(random() * 102				) + 1				):
																								_lowerCAmelCase  						=			floor(random() * c				) + 1
																								if n != i:
																														self.add_pair(_lowercase   ,       _lowercase   ,       1				)




						def  _lowercase     ( self   ,       _lowercase=-2				):

												"""simple docstring"""



												_lowerCAmelCase  						=			deque()
												_lowerCAmelCase  						=			[]
												if s == -2:
																		_lowerCAmelCase  						=			list(self.graph				)[0]
												d.append(_lowercase				)
												visited.append(_lowercase				)
												while d:
																		_lowerCAmelCase  						=			d.popleft()
																		if len(self.graph[s]				) != 0:
																								for node in self.graph[s]:
																														if visited.count(node[1]				) < 1:
																																				d.append(node[1]				)
																																				visited.append(node[1]				)
												return visited




						def  _lowercase     ( self   ,       _lowercase				):

												"""simple docstring"""



												return len(self.graph[u]				)




						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			list(self.graph				)[0]
												stack.append(_lowercase				)
												visited.append(_lowercase				)
												_lowerCAmelCase  						=			-2
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			s
												_lowerCAmelCase  						=			False
												_lowerCAmelCase  						=			set()

												while True:
																		# check if there is any non isolated nodes
																		if len(self.graph[s]				) != 0:
																								_lowerCAmelCase  						=			s
																								for node in self.graph[s]:
																														if (
																														    visited.count(node[1]				) > 0
																														    and node[1] != parent
																														    and indirect_parents.count(node[1]				) > 0
																														    and not on_the_way_back
																														):
																																				_lowerCAmelCase  						=			len(_lowercase				) - 1
																																				while len_stack >= 0:
																																										if stack[len_stack] == node[1]:
																																																anticipating_nodes.add(node[1]				)
																																																break
																																										else:
																																																anticipating_nodes.add(stack[len_stack]				)
																																																len_stack -= 1
																														if visited.count(node[1]				) < 1:
																																				stack.append(node[1]				)
																																				visited.append(node[1]				)
																																				_lowerCAmelCase  						=			node[1]
																																				break

            # check if all the children are visited
																		if s == ss:
																								stack.pop()
																								_lowerCAmelCase  						=			True
																								if len(_lowercase				) != 0:
																														_lowerCAmelCase  						=			stack[len(_lowercase				) - 1]
																		else:
																								_lowerCAmelCase  						=			False
																								indirect_parents.append(_lowercase				)
																								_lowerCAmelCase  						=			s
																								_lowerCAmelCase  						=			ss

																		# check if se have reached the starting point
																		if len(_lowercase				) == 0:
																								return list(_lowercase				)




						def  _lowercase     ( self				):

												"""simple docstring"""



												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			list(self.graph				)[0]
												stack.append(_lowercase				)
												visited.append(_lowercase				)
												_lowerCAmelCase  						=			-2
												_lowerCAmelCase  						=			[]
												_lowerCAmelCase  						=			s
												_lowerCAmelCase  						=			False
												_lowerCAmelCase  						=			set()

												while True:
																		# check if there is any non isolated nodes
																		if len(self.graph[s]				) != 0:
																								_lowerCAmelCase  						=			s
																								for node in self.graph[s]:
																														if (
																														    visited.count(node[1]				) > 0
																														    and node[1] != parent
																														    and indirect_parents.count(node[1]				) > 0
																														    and not on_the_way_back
																														):
																																				_lowerCAmelCase  						=			len(_lowercase				) - 1
																																				while len_stack_minus_one >= 0:
																																										if stack[len_stack_minus_one] == node[1]:
																																																anticipating_nodes.add(node[1]				)
																																																break
																																										else:
																																																return True
																														if visited.count(node[1]				) < 1:
																																				stack.append(node[1]				)
																																				visited.append(node[1]				)
																																				_lowerCAmelCase  						=			node[1]
																																				break

            # check if all the children are visited
																		if s == ss:
																								stack.pop()
																								_lowerCAmelCase  						=			True
																								if len(_lowercase				) != 0:
																														_lowerCAmelCase  						=			stack[len(_lowercase				) - 1]
																		else:
																								_lowerCAmelCase  						=			False
																								indirect_parents.append(_lowercase				)
																								_lowerCAmelCase  						=			s
																								_lowerCAmelCase  						=			ss

																		# check if se have reached the starting point
																		if len(_lowercase				) == 0:
																								return False




						def  _lowercase     ( self				):

												"""simple docstring"""



												return list(self.graph				)




						def  _lowercase     ( self   ,       _lowercase=-2   ,       _lowercase=-1				):

												"""simple docstring"""



												_lowerCAmelCase  						=			time()
												self.dfs(_lowercase   ,       _lowercase				)
												_lowerCAmelCase  						=			time()
												return end - begin




						def  _lowercase     ( self   ,       _lowercase=-2				):

												"""simple docstring"""



												_lowerCAmelCase  						=			time()
												self.bfs(_lowercase				)
												_lowerCAmelCase  						=			time()
												return end - begin


'''simple docstring'''



import os


def A				():
						with open(os.path.dirname(__lowerCamelCase		) + """/grid.txt"""		) as f:
												_lowerCAmelCase  						=			[]  # noqa: E741
												for _ in range(20		):
																		l.append([int(__lowerCamelCase		) for x in f.readline().split()]		)

												_lowerCAmelCase  						=			0

												# right
												for i in range(20		):
																		for j in range(17		):
																								_lowerCAmelCase  						=			l[i][j] * l[i][j + 1] * l[i][j + 2] * l[i][j + 3]
																								if temp > maximum:
																														_lowerCAmelCase  						=			temp

        # down
												for i in range(17		):
																		for j in range(20		):
																								_lowerCAmelCase  						=			l[i][j] * l[i + 1][j] * l[i + 2][j] * l[i + 3][j]
																								if temp > maximum:
																														_lowerCAmelCase  						=			temp

        # diagonal 1
												for i in range(17		):
																		for j in range(17		):
																								_lowerCAmelCase  						=			l[i][j] * l[i + 1][j + 1] * l[i + 2][j + 2] * l[i + 3][j + 3]
																								if temp > maximum:
																														_lowerCAmelCase  						=			temp

        # diagonal 2
												for i in range(17		):
																		for j in range(3			,     20		):
																								_lowerCAmelCase  						=			l[i][j] * l[i + 1][j - 1] * l[i + 2][j - 2] * l[i + 3][j - 3]
																								if temp > maximum:
																														_lowerCAmelCase  						=			temp
												return maximum


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