import sys readline = sys.stdin.readline from random import * from time import * seed(314) N = int(readline()) sTime = time() L = [] for i in range(N): L.append(list(map(int, readline().split()))) def f(tt, val): A = [0] * 64 B = [0] * 64 for s in range(1 << 6): for i in range(N//2): for j in range(i + 1, N//2): v = 1 for k in range(6): if (s >> k) & 1: v *= max(L[i][k], L[j][k]) A[s] = max(A[s], v) for s in range(1 << 6): for i in range(N//2, N): for j in range(i + 1, N): v = 1 for k in range(6): if (s >> k) & 1: v *= max(L[i][k], L[j][k]) B[s] = max(B[s], v) ans = 0 for i in range(1 << 6): ans = max(ans, A[i] * B[63 - i]) return ans ans = 0 while time() - sTime < 3.0: shuffle(L) ans = max(ans, f(sTime, ans)) print(ans)