#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 2;
long long dp[MAX][64];
long long left1[5][MAX], down[5][MAX];
long long n, m;
bool mask[64][5];
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long c = 1; c < m; c++) {
    for (long long r = 0; r < n; r++) {
      scanf("%lld", &left1[r][c]);
    }
  }
  for (long long c = 0; c < m; c++) {
    for (long long r = 0; r < n; r++) {
      scanf("%lld", &down[r][c]);
    }
  }
  long long bound = 1 << n, fix, t1;
  for (long long st = 0; st < bound; st++) {
    for (long long pos = 0; pos < n; pos++) {
      mask[st][pos] = (st >> pos) & 1;
    }
  }
  for (long long c = 1; c < m; c++) {
    for (long long st = 0; st < bound; st++) {
      fix = 0, dp[c][st] = LLONG_MAX;
      for (long long r = 0; r < n; r++) {
        long long nxt = r + 1 < n ? r + 1 : 0;
        if ((mask[st][r] ^ mask[st][nxt]) == 1) {
          fix += down[r][c];
        }
      }
      for (long long prev = 0; prev < bound; prev++) {
        if (c == 1 && prev != 0) break;
        t1 = 0;
        for (long long r = 0; r < n; r++) {
          if ((mask[st][r] ^ mask[prev][r]) == 1) {
            t1 += left1[r][c];
          }
        }
        dp[c][st] = std::min(dp[c][st], dp[c - 1][prev] + t1 + fix);
      }
    }
  }
  printf("%lld\n", dp[m - 1][bound - 1]);
  return 0;
}
