#include <bits/stdc++.h>
using namespace std;
const int maxn = 5, maxm = 100010;
int n, m, h[maxm][maxn], v[maxm][maxn];
long long f[maxm][1 << maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m - 1; i++)
    for (int j = 0; j < n; j++) scanf("%d", &h[i][j]);
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) scanf("%d", &v[i][j]);
  for (int i = 1; i < 1 << n; i++) f[0][i] = 1LL << 60LL;
  f[0][0] = 0;
  for (int i = 1; i < m; i++)
    for (int opt = 0; opt < 1 << n; opt++) {
      f[i][opt] = 1LL << 60LL;
      long long s = 0;
      for (int j = 0; j < n; j++)
        s += ((opt & (1 << ((j + 1) % n))) > 0 != (opt & (1 << j)) > 0) *
             v[i][j];
      for (int opt0 = 0; opt0 < 1 << n; opt0++) {
        long long ss = 0;
        for (int j = 0; j < n; j++)
          ss += ((opt & (1 << j)) != (opt0 & (1 << j))) * h[i - 1][j];
        f[i][opt] = min(f[i][opt], f[i - 1][opt0] + s + ss);
      }
    }
  printf("%I64d\n", f[m - 1][(1 << n) - 1]);
  return 0;
}
