#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define rep(i, n) for(int i=0;i=0;--i) const int inf=1e9+7; const ll mod=1e9+7; const ll big=1e18; const double PI=2*asin(1); int N; int A[3][18]; int DP[(1<<18)][18][3]; bool can[(1<<18)][18][3]; int ans=0; int solve(int S, int x, int k) { if(DP[S][x][k]>0) { ans = max(ans, DP[S][x][k]); return DP[S][x][k]; } if(S==0) { can[S][x][k] = true; DP[S][x][k] = A[k][x]; ans = max(ans, DP[S][x][k]); return DP[S][x][k] = A[k][x]; } int tmp1, tmp2, tmp3, tmp4; int tmpans; int num = 0; for(int i=0;itmp3 || tmp2>tmp4) continue; else { tmpans = solve(S^(1<>N; for(int i=0;i>A[0][i]>>A[1][i]>>A[2][i]; int S = (1<