#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n;
int a[2][22][22];
int g[22][22];
int ans;
int wl[22], wr[22], lk[22], bef[22], d[22];
bool used[22];
void dfs(int now, int day, int night) {
  if (now > n) {
    ans = max(ans, -wr[0]);
    return;
  }
  int tpwl[22], tpwr[22], tplk[22];
  for (int ty = 0; ty < 2; ty++) {
    if (day + ty > n / 2 || night + (ty ^ 1) > n / 2) continue;
    for (int i = 0; i <= n; i++)
      tpwl[i] = wl[i], tpwr[i] = wr[i], tplk[i] = lk[i];
    for (int i = 1; i <= n; i++) g[now][i] = a[ty][i][now];
    for (int i = 0; i <= n; i++) used[i] = 0, d[i] = inf;
    lk[0] = now;
    int r = 0;
    while (lk[r] != -1) {
      used[r] = 1;
      int l = lk[r], nxtr;
      int slack = inf;
      for (int i = 1; i <= n; i++) {
        if (!used[i]) {
          int t = -g[l][i] + wl[l] + wr[i];
          if (t < d[i]) {
            d[i] = t;
            bef[i] = r;
          }
          if (d[i] < slack) {
            slack = d[i];
            nxtr = i;
          }
        }
      }
      for (int i = 0; i <= n; i++) {
        if (used[i]) {
          wl[lk[i]] -= slack;
          wr[i] += slack;
        } else
          d[i] -= slack;
      }
      r = nxtr;
    }
    while (r) {
      lk[r] = lk[bef[r]];
      r = bef[r];
    }
    dfs(now + 1, day + ty, night + (ty ^ 1));
    for (int i = 0; i <= n; i++)
      wl[i] = tpwl[i], wr[i] = tpwr[i], lk[i] = tplk[i];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++) scanf("%d", &a[i][j][k]);
  }
  memset(lk, -1, sizeof(lk));
  dfs(1, 0, 0);
  printf("%d\n", ans);
}
