#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int h[N][7], w[N][7], n, m;
long long f[40];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(m - 1); i++)
    for (int j = (int)(0); j <= (int)(n - 1); j++) scanf("%d", &w[i][j]);
  for (int i = (int)(0); i <= (int)(m - 1); i++)
    for (int j = (int)(0); j <= (int)(n - 1); j++) scanf("%d", &h[i][j]);
  for (int i = (int)(1); i <= (int)((1 << n) - 1); i++) f[i] = (1ll << 60);
  for (int i = (int)(1); i <= (int)(m - 1); i++)
    for (int j = (int)(0); j <= (int)((1 << n) - 1); j++) {
      for (int k = (int)(0); k <= (int)(n - 1); k++)
        if (!(j & (1 << k)))
          f[j ^ (1 << k)] = min(f[j ^ (1 << k)], f[j] + w[i][k]);
      for (int k = (int)(0); k <= (int)(n - 1); k++)
        if (((j >> k) ^ (j >> ((k + 1) % n))) & 1) f[j] += h[i][k];
    }
  printf("%lld", f[(1 << n) - 1]);
}
