import sys readline = sys.stdin.readline N = int(readline()) L = [] for i in range(N): L.append(list(map(int, readline().split()))) 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]) print(ans)