x=[((0,), (1,), (2,), (3, 4, 5)),((0,), (1,), (2, 3), (4, 5)),((0,), (1,), (2, 3, 4), (5,)),((0,), (1,), (2, 3, 5), (4,)),((0,), (1,), (2, 4), (3, 5)),((0,), (1,), (2, 4, 5), (3,)),((0,), (1,), (2, 5), (3, 4)),((0,), (1, 2), (3,), (4, 5)),((0,), (1, 2), (3, 4), (5,)),((0,), (1, 2), (3, 5), (4,)),((0,), (1, 2, 3), (4,), (5,)),((0,), (1, 2, 4), (3,), (5,)),((0,), (1, 2, 5), (3,), (4,)),((0,), (1, 3), (2,), (4, 5)),((0,), (1, 3), (2, 4), (5,)),((0,), (1, 3), (2, 5), (4,)),((0,), (1, 3, 4), (2,), (5,)),((0,), (1, 3, 5), (2,), (4,)),((0,), (1, 4), (2,), (3, 5)),((0,), (1, 4), (2, 3), (5,)),((0,), (1, 4), (2, 5), (3,)),((0,), (1, 4, 5), (2,), (3,)),((0,), (1, 5), (2,), (3, 4)),((0,), (1, 5), (2, 3), (4,)),((0,), (1, 5), (2, 4), (3,)),((0, 1), (2,), (3,), (4, 5)),((0, 1), (2,), (3, 4), (5,)),((0, 1), (2,), (3, 5), (4,)),((0, 1), (2, 3), (4,), (5,)),((0, 1), (2, 4), (3,), (5,)),((0, 1), (2, 5), (3,), (4,)),((0, 1, 2), (3,), (4,), (5,)),((0, 1, 3), (2,), (4,), (5,)),((0, 1, 4), (2,), (3,), (5,)),((0, 1, 5), (2,), (3,), (4,)),((0, 2), (1,), (3,), (4, 5)),((0, 2), (1,), (3, 4), (5,)),((0, 2), (1,), (3, 5), (4,)),((0, 2), (1, 3), (4,), (5,)),((0, 2), (1, 4), (3,), (5,)),((0, 2), (1, 5), (3,), (4,)),((0, 2, 3), (1,), (4,), (5,)),((0, 2, 4), (1,), (3,), (5,)),((0, 2, 5), (1,), (3,), (4,)),((0, 3), (1,), (2,), (4, 5)),((0, 3), (1,), (2, 4), (5,)),((0, 3), (1,), (2, 5), (4,)),((0, 3), (1, 2), (4,), (5,)),((0, 3), (1, 4), (2,), (5,)),((0, 3), (1, 5), (2,), (4,)),((0, 3, 4), (1,), (2,), (5,)),((0, 3, 5), (1,), (2,), (4,)),((0, 4), (1,), (2,), (3, 5)),((0, 4), (1,), (2, 3), (5,)),((0, 4), (1,), (2, 5), (3,)),((0, 4), (1, 2), (3,), (5,)),((0, 4), (1, 3), (2,), (5,)),((0, 4), (1, 5), (2,), (3,)),((0, 4, 5), (1,), (2,), (3,)),((0, 5), (1,), (2,), (3, 4)),((0, 5), (1,), (2, 3), (4,)),((0, 5), (1,), (2, 4), (3,)),((0, 5), (1, 2), (3,), (4,)),((0, 5), (1, 3), (2,), (4,)),((0, 5), (1, 4), (2,), (3,))] y=[(0,), (0, 1), (0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 1, 5), (0, 2), (0, 2, 3), (0, 2, 4), (0, 2, 5), (0, 3), (0, 3, 4), (0, 3, 5), (0, 4), (0, 4, 5), (0, 5), (1,), (1, 2), (1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3), (1, 3, 4), (1, 3, 5), (1, 4), (1, 4, 5), (1, 5), (2,), (2, 3), (2, 3, 4), (2, 3, 5), (2, 4), (2, 4, 5), (2, 5), (3,), (3, 4), (3, 4, 5), (3, 5), (4,), (4, 5), (5,)] n=int(input()) a=[0]*n for i in range(n): a[i]=list(map(int,input().split())) d={} for s in y: mx=0 for i in range(n): tmp=1 for j in s: tmp*=a[i][j] mx=max(mx,tmp) d[s]=mx ans=0 for s1,s2,s3,s4 in x: ans=max(ans,d[s1]*d[s2]*d[s3]*d[s4]) print(ans)