#include <bits/stdc++.h>
using namespace std;
int read() {
  int X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}
const int N = 5 + 5, M = 100000 + 5;
int n, m, h[N][M], v[N][M];
long long dp[1 << 5];
int main() {
  n = read(), m = read();
  for (int i = 1; i < m; ++i)
    for (int j = 0; j < n; ++j) h[j][i] = read();
  for (int i = 1; i <= m; ++i)
    for (int j = 0; j < n; ++j) v[j][i] = read();
  memset(dp, 0x3f, sizeof(dp)), dp[(1 << n) - 1] = 0;
  for (int i = 1; i < m; ++i) {
    for (int S = (1 << n) - 1; ~S; --S)
      for (int j = 0; j < n; ++j)
        if (S & (1 << j))
          dp[S ^ (1 << j)] = min(dp[S ^ (1 << j)], dp[S] + h[j][i]);
    for (int S = 0; S < 1 << n; ++S)
      for (int j = 0; j < n; ++j)
        if (((S >> j) & 1) != ((S >> ((j + 1) % n)) & 1)) dp[S] += v[j][i + 1];
  }
  printf("%lld\n", dp[0]);
  return 0;
}
