#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
inline int isSet(int mask, int i) { return (mask >> i) & 1; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  int n, m;
  cin >> n >> m;
  long long a[m][n], b[m][n];
  for (int i = 1; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> b[i][j];
    }
  }
  vector<long long> dp(1 << n, inf);
  dp[0] = 0;
  for (int i = 1; i < m; i++) {
    vector<long long> ndp(1 << n, inf);
    for (int cmask = 0; cmask < (1 << n); cmask++) {
      long long cost = 0;
      for (int j = 0; j < n; j++) {
        if (isSet(cmask, j) ^ isSet(cmask, (j + 1) % n)) cost += b[i][j];
      }
      for (int pmask = 0; pmask < (1 << n); pmask++) {
        long long tmp = cost;
        for (int j = 0; j < n; j++) {
          if (isSet(cmask, j) ^ isSet(pmask, j)) tmp += a[i][j];
        }
        ndp[cmask] = min(ndp[cmask], dp[pmask] + tmp);
      }
    }
    dp = ndp;
  }
  cout << dp[(1 << n) - 1];
  return 0;
}
