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