#include <bits/stdc++.h>
using namespace std;
const int mm = 100005;
const long long inf = (long long)1000000000 * 1000000000;
int n, m, c[7];
int a[mm][7], b[mm][7];
long long f[35], g[35], h[35];
void read(int &x) {
  char ch = getchar();
  for (; ch < 48; ch = getchar())
    ;
  for (x = 0; ch >= 48; ch = getchar()) x = x * 10 + ch - 48;
}
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= m; ++i)
    for (int j = 1; j <= n; ++j) read(a[i][j]);
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= n; ++j) read(b[i][j]);
}
void work() {
  for (int i = 1; i < (1 << n); ++i) g[i] = inf;
  for (int i = 2; i <= m; ++i) {
    memcpy(f, g, sizeof(g));
    for (int j = 0; j < (1 << n); ++j) {
      g[j] = inf;
      h[j] = 0;
      for (int k = 1, l = j; k <= n; ++k, l >>= 1)
        if (l & 1) h[j] += a[i][k];
    }
    for (int j = 0; j < (1 << n); ++j)
      for (int k = 0; k < (1 << n); ++k) g[j] = min(g[j], f[k] + h[j ^ k]);
    for (int j = 0; j < (1 << n); ++j) {
      for (int k = 1, l = j; k <= n; ++k, l >>= 1) c[k] = l & 1;
      c[n + 1] = c[1];
      for (int k = 1; k <= n; ++k)
        if (c[k] ^ c[k + 1]) g[j] += b[i][k];
    }
  }
  printf("%I64d\n", g[(1 << n) - 1]);
}
int main() {
  init();
  work();
  return 0;
}
