#include <bits/stdc++.h>
using namespace std;
const int N = 6;
const int M = 101000;
const long long inf = 1LL << 61;
int n, m, cx[M][N], cy[M][N];
long long d[1000];
int main() {
  int i, j, k;
  cin >> n >> m;
  for (i = 1; i < m; ++i)
    for (j = 1; j <= n; ++j) cin >> cx[i][j];
  for (i = 1; i <= m; ++i)
    for (j = 1; j <= n; ++j) cin >> cy[i][j];
  for (i = 0; i < 1000; ++i) d[i] = inf;
  d[0] = 0;
  for (i = 1; i < m; ++i) {
    for (j = 0; j < (1 << n); ++j)
      if (d[j] != inf)
        for (k = 0; k < n; ++k) {
          int b1 = ((j >> k) & 1), b2 = ((j >> ((k + 1) % n)) & 1);
          if (b1 != b2) d[j] += cy[i][k + 1];
        }
    for (k = 0; k < n; ++k)
      for (j = 0; j < (1 << n); ++j)
        d[j] = min(d[j], d[j ^ (1 << k)] + cx[i][k + 1]);
  }
  cout << d[(1 << n) - 1];
  return 0;
}
