#include <bits/stdc++.h>
using std::vector;
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  int rows, cols;
  std::cin >> rows >> cols;
  vector<vector<int>> hor(rows, vector<int>(cols - 1));
  for (int i = 0; i < cols - 1; ++i) {
    for (int j = 0; j < rows; ++j) {
      std::cin >> hor[j][i];
    }
  }
  vector<vector<int>> ver(rows, vector<int>(cols));
  for (int i = 0; i < cols; ++i) {
    for (int j = 0; j < rows; ++j) {
      std::cin >> ver[j][i];
    }
  }
  int msk = 1 << rows;
  vector<int64_t> masks(msk, -1);
  masks[0] = 0;
  for (int col = 1; col < cols; ++col) {
    for (int row = 0; row < rows; ++row) {
      vector<int64_t> next(msk, -1);
      for (int prev = 0; prev < msk; ++prev) {
        if (masks[prev] != -1) {
          int64_t val_out = masks[prev];
          int64_t val_in = val_out;
          if (prev & (1 << row))
            val_out += hor[row][col - 1];
          else
            val_in += hor[row][col - 1];
          if (row) {
            if (prev & (1 << (row - 1))) {
              val_out += ver[row - 1][col];
            } else {
              val_in += ver[row - 1][col];
            }
          }
          if (row == rows - 1) {
            if (prev & 1) {
              val_out += ver[row][col];
            } else {
              val_in += ver[row][col];
            }
          }
          if (next[prev | (1 << row)] == -1 ||
              next[prev | (1 << row)] > val_in) {
            next[prev | (1 << row)] = val_in;
          }
          int out = (prev & ~(1 << row));
          if (next[out] == -1 || next[out] > val_out) {
            next[out] = val_out;
          }
        }
      }
      masks = std::move(next);
    }
  }
  std::cout << masks.back();
  return 0;
}
