#include <bits/stdc++.h>
using namespace std;
int rd() { return RAND_MAX == 32767 ? ((rand() << 15) ^ rand()) : rand(); }
const long long inf = 1000000000000000000LL;
int capx[100010][5], capy[100010][5];
long long f[1 << 5];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m - 1; i++)
    for (int j = 0; j < n; j++) cin >> capx[i][j];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) cin >> capy[i][j];
  fill(f, f + (1 << n), inf);
  f[(1 << n) - 1] = 0;
  for (int i = 0; i < m - 1; i++) {
    for (int v = 0; v < (1 << n); v++)
      for (int j = 0; j < n; j++)
        if ((v >> j & 1) ^ (v >> (j + 1) % n & 1)) f[v] += capy[i][j];
    for (int j = n - 1; j >= 0; j--)
      for (int v = 0; v < (1 << n); v++) {
        f[v ^ 1 << j] = min(f[v ^ 1 << j], f[v] + capx[i][j]);
        f[v] = min(f[v], f[v ^ 1 << j] + capx[i][j]);
      }
  }
  cout << f[0] << endl;
  return 0;
}
