#include <bits/stdc++.h>
const long long inf = 1e18;
long long dp[2][1 << 6], sh[1 << 6], sv[1 << 6];
int v[100010][6], h[100010][6];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i < m; 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]);
  int now = 0, pre = 1;
  for (int i = 1; i < (1 << n); i++) dp[0][i] = inf;
  dp[0][0] = 0;
  for (int i = 1; i < m; i++) {
    now ^= 1, pre ^= 1;
    for (int j = 1; j < (1 << n); j++) dp[now][j] = inf;
    dp[now][0] = 0;
    sh[0] = sv[0] = 0;
    for (int j = 1; j < (1 << n); j++) {
      int k = __builtin_ctz(j);
      sh[j] = sh[j ^ (1 << k)] + h[i][k];
      sv[j] = sv[j ^ (1 << k)] + v[i][k];
    }
    for (int j = 0; j < (1 << n); j++) {
      for (int k = j;; k = (k - 1) & j) {
        dp[now][j] = dp[pre][k] + sh[j ^ k] < dp[now][j]
                         ? dp[pre][k] + sh[j ^ k]
                         : dp[now][j];
        if (k == 0) break;
      }
      dp[now][j] += sv[j ^ (j >> 1) ^ ((j & 1) << (n - 1))];
    }
  }
  printf("%I64d\n", dp[now][(1 << n) - 1]);
  return 0;
}
