#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][20]; int DP[(1<<18)][20][3]; int solve(int S, int x, int k) { if(DP[S][x][k]>0) return DP[S][x][k]; if(S==0) { DP[S][x][k] = A[k][x]; } int tmp1, tmp2, tmp3, tmp4; for(int i=0;itmp3 || tmp2>tmp4) continue; else DP[S][x][k] = max(DP[S][x][k], solve(S^(1<>N; for(int i=0;i>A[0][i]>>A[1][i]>>A[2][i]; int ans = 0; int S = (1<