#include <bits/stdc++.h>
using namespace std;
int n, m;
long long D[101000][32], INF = 1e18, S[32], S2[32];
int W[101000][6], H[101000][6];
int main() {
  int i, j, k, l;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    for (j = 0; j < (1 << n); j++) D[i][j] = INF;
  }
  D[1][0] = 0;
  for (i = 1; i <= m - 1; i++) {
    for (j = 0; j < n; j++) scanf("%d", &W[i][j]);
  }
  for (i = 1; i <= m; i++) {
    for (j = 0; j < n; j++) scanf("%d", &H[i][j]);
  }
  for (i = 1; i < m; i++) {
    for (j = 0; j < (1 << n); j++) {
      S[j] = 0;
      S2[j] = 0;
      for (k = 0; k < n; k++) {
        if ((1 << k) & j) S[j] += W[i][k];
        int tk = (k + 1) % n;
        if ((((1 << k) & j) != 0) != (((1 << tk) & j) != 0)) {
          S2[j] += H[i + 1][k];
        }
      }
    }
    for (j = 0; j < (1 << n); j++) {
      for (k = 0; k < (1 << n); k++) {
        D[i + 1][k] = min(D[i + 1][k], D[i][j] + S[j ^ k] + S2[k]);
      }
    }
  }
  printf("%lld\n", D[m][(1 << n) - 1]);
}
