#include using namespace std; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout<> n; using P = pair; vector

a; rep (i, n) { int x, y, z; cin >> x >> y >> z; P temp1({min(x, y), max(x, y)}, {z, i}); P temp2({min(z, y), max(z, y)}, {x, i}); P temp3({min(x, z), max(x, z)}, {y, i}); a.push_back(temp1); a.push_back(temp2); a.push_back(temp3); } sort(all(a)); int m = a.size(); vii dp1(m + 1, vi(1 << n, -inf)), dp2(m + 1, vi(1 << n, -inf)); dp1[0][0] = 0; int ans = 0; rep (i, m) { rep (j, m + 1) fill(all(dp2[j]), -inf); rep (j, m + 1) { rep (k, 1 << n) { if (dp1[j][k] == -inf) continue; chmax(dp2[j][k], dp1[j][k]); int nh = dp1[j][k] + a[i].second.first; int u = a[i].second.second; if (k & (1 << u)) continue; int nk = k | (1 << u); int x = a[i].first.first, y = a[i].first.second; if (j != 0) { int px = a[j - 1].first.first, py = a[j - 1].first.second; if (px > x or py > y) continue; } chmax(dp2[i + 1][nk], nh); chmax(ans, nh); } } swap(dp1, dp2); } cout << ans << endl; }