#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<vector<int>> a(n,vector<int>(3));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
        sort(a[i].begin(),a[i].end());
    }
    int dp[1<<n][n][3]={};
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            dp[1<<i][i][j]=a[i][j];
        }
    }
    int p[3]={1,0,0};
    int q[3]={2,2,1};
    for(int i=1;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<3;k++){
                if(dp[i][j][k]==0){
                    continue;
                }
                for(int l=0;l<n;l++){
                    if(i&(1<<l)){
                        continue;
                    }
                    for(int m=0;m<3;m++){
                        if(a[l][p[m]]<=a[j][p[k]]&&a[l][q[m]]<=a[j][q[k]]){
                            chmax(dp[i|(1<<l)][l][m],dp[i][j][k]+a[l][m]);
                        }
                    }
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<3;k++){
                chmax(ans,dp[i][j][k]);
            }
        }
    }
    cout << ans << endl;
}