#include using namespace std; #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<> #define rev(x) reverse(x); using ll=long long; using vl=vector; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[9]={0,1,-1,0,1,1,-1,-1,0}; const ll dx[9]={1,0,0,-1,1,-1,1,-1,0}; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } vector ds; void dfs(ll d,vl now,ll cum){ if(d==4){ if(cum==63){ ds.emplace_back(now); } return; } d++; rep(bit,1<<6){ if(cum&bit)continue; now.emplace_back(bit); cum^=bit; dfs(d,now,cum); now.pop_back(); cum^=bit; } } int main(){ ll n;cin >> n; vl hog;dfs(0,hog,0); vvl g(n,vl(6)); rep(i,n)rep(j,6){ cin >> g[i][j]; } vl dp(1<<6); rep(bit,1<<6){ rep(i,n){ ll now=1; rep(j,6){ if(bit>>j&1)now*=g[i][j]; } chmax(dp[bit],now); } } ll ans=0; for(auto v:ds){ ll ret=1; for(auto p:v)ret*=dp[p]; chmax(ans,ret); } cout << ans << endl; }