#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)

int N;
i64 A[10000][6];
int maxi[64] = {};

int main() {
    cin >> N;
    rep(i,N) rep(j,6) cin >> A[i][j];
    rep(b,64){
        i64 maxscore = 0;
        rep(i,N){
            i64 score = 1;
            rep(t,6) if((b >> t) & 1) score *= A[i][t];
            if(score > maxscore){ maxi[b] = i; maxscore = score; }
        }
    }


    i64 ans = 0;
    rep(i,64) rep(j,i) rep(k,j) rep(l,k){
        i64 maxA[6] = {};
        rep(t,6) maxA[t] = max({ A[maxi[i]][t], A[maxi[j]][t], A[maxi[k]][t], A[maxi[l]][t] });
        i64 tmp = 1;
        rep(t,6) tmp *= maxA[t];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;