#include <bits/stdc++.h>
const long long MAX = 1000000000000;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int nn, mm;
  std::cin >> nn >> mm;
  std::vector<std::vector<long long>> horiz(nn, std::vector<long long>(mm - 1));
  std::vector<std::vector<long long>> vert(nn, std::vector<long long>(mm));
  for (int j = 0; j < mm - 1; ++j) {
    for (int i = 0; i < nn; ++i) std::cin >> horiz[i][j];
  }
  for (int j = 0; j < mm; ++j) {
    for (int i = 0; i < nn; ++i) std::cin >> vert[i][j];
  }
  int masks = 1 << nn;
  std::vector<long long> prev(1 << nn, MAX);
  std::vector<long long> next(1 << nn, 0);
  prev[0] = 0;
  for (int kk = 0; kk < mm - 1; ++kk) {
    next.assign(1 << nn, MAX);
    for (int ii = 0; ii < masks; ++ii) {
      long long vertcut = 0;
      for (int ll = 0; ll < nn - 1; ++ll) {
        if (((ii >> ll) & 1) ^ ((ii >> (ll + 1)) & 1))
          vertcut += vert[ll][kk + 1];
      }
      if (((ii >> (nn - 1)) & 1) ^ (ii & 1)) vertcut += vert[nn - 1][kk + 1];
      long long horcut = MAX;
      for (int jj = 0; jj < masks; ++jj) {
        long long cut = 0;
        for (int ll = 0; ll < nn; ++ll) {
          if (((ii >> ll) & 1) ^ ((jj >> ll) & 1)) {
            cut += horiz[ll][kk];
          }
        }
        horcut = std::min(horcut, cut + prev[jj]);
      }
      next[ii] = horcut + vertcut;
    }
    prev = next;
  }
  std::cout << next[masks - 1] << std::endl;
  return 0;
}
