#include <bits/stdc++.h>
using namespace std;
int n, m, k;
bool debug = false;
int v[100005][6], h[100005][6];
long long dp[1 << 6];
int main() {
  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]);
  for (int i = 1; i < 1 << 6; i++) dp[i] = -1;
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < 1 << n; j++) {
      for (int k = 0; k < n; k++)
        if (!((j >> k) & 1)) {
          if (dp[j | 1 << k] == -1)
            dp[j | 1 << k] = dp[j] + (long long)h[i][k];
          else
            dp[j | 1 << k] = min(dp[j | 1 << k], dp[j] + (long long)h[i][k]);
        }
      for (int k = 0; k < n; k++) {
        if ((j >> k & 1) ^ (j >> ((k + 1) % n) & 1)) {
          dp[j] += v[i][k];
        }
      }
    }
  }
  printf("%I64d\n", dp[(1 << n) - 1]);
  return 0;
}
