#include <bits/stdc++.h>
using namespace std;
int H[100000][5], V[100000][5];
long long dp[32];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i < m; ++i)
    for (int j = 0; j < n; ++j) cin >> H[i][j];
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < n; ++j) cin >> V[i][j];
  for (int i = 1; i < (1 << n); ++i) dp[i] = 1e18;
  const int sz = 1 << n;
  for (int i = 1; i < m; ++i) {
    for (int j = 0; j < sz; ++j) {
      for (int k = 0; k < n; ++k) {
        if (!(j & (1 << k))) {
          auto &t = dp[j | (1 << k)];
          const auto &nt = dp[j] + H[i][k];
          if (nt < t) t = nt;
        }
      }
      for (int k = 0; k < n; ++k) {
        if ((((j >> k)) ^ ((j >> ((k + 1) % n)))) & 1) dp[j] += V[i][k];
      }
    }
  }
  cout << dp[sz - 1] << endl;
  return 0;
}
