#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
int main() {
  int width, height;
  cin.sync_with_stdio(false);
  cin >> height >> width;
  vector<vector<long long>> wcapacity(width - 1, vector<long long>(height));
  vector<vector<long long>> hcapacity(width, vector<long long>(height));
  for (int i = 0; i < width - 1; ++i) {
    for (int j = 0; j < height; ++j) {
      cin >> wcapacity[i][j];
    }
  }
  for (int i = 0; i < width; ++i) {
    for (int j = 0; j < height; ++j) {
      cin >> hcapacity[i][j];
    }
  }
  int masks = (1 << height);
  vector<vector<long long>> dp(width, vector<long long>(masks, (1ll << 60)));
  dp[0][masks - 1] = 0;
  vector<int> mask(1 << masks, 0);
  for (int i = 0; i < masks; ++i) {
    for (int j = 0; j < height; ++j) {
      if (static_cast<bool>(i & (1 << j)) !=
          static_cast<bool>(i & (1 << ((j + 1) % height)))) {
        mask[i] |= (1 << j);
      }
    }
  }
  for (int pos = 1; pos < width; ++pos) {
    vector<long long> wpsum(masks, 0), hpsum(masks, 0);
    for (int i = 0; i < masks; ++i) {
      for (int j = 0; j < height; ++j) {
        if ((1 << j) & mask[i]) {
          hpsum[i] += hcapacity[pos][j];
        }
        if ((1 << j) & i) {
          wpsum[i] += wcapacity[pos - 1][j];
        }
      }
    }
    for (int i = 0; i < masks; ++i) {
      for (int j = 0; j < masks; ++j) {
        dp[pos][j] =
            std::min(dp[pos][j], dp[pos - 1][i] + wpsum[i ^ j] + hpsum[j]);
      }
    }
  }
  cout << dp[width - 1][0] << endl;
  return 0;
}
