#include <bits/stdc++.h>
using namespace std;
int X, Y;
long long xcap[100010][5], ycap[100010][5];
long long dp[100010][(1 << 5)];
long long xsum[(1 << 5)], ysum[(1 << 5)];
int boundary[(1 << 5)];
int main(void) {
  int i, j, x, tmp;
  scanf("%d%d", &Y, &X);
  for ((i) = 0; (i) < (int)(X - 1); (i)++)
    for ((j) = 0; (j) < (int)(Y); (j)++) {
      scanf("%d", &tmp);
      xcap[i][j] = tmp;
    }
  for ((i) = 0; (i) < (int)(X); (i)++)
    for ((j) = 0; (j) < (int)(Y); (j)++) {
      scanf("%d", &tmp);
      ycap[i][j] = tmp;
    }
  for ((i) = 0; (i) < (int)((1 << Y)); (i)++)
    for ((j) = 0; (j) < (int)(Y); (j)++) {
      bool b1 = ((i & (1 << j)) == 0);
      int j2 = (j + 1) % Y;
      bool b2 = ((i & (1 << j2)) == 0);
      if (b1 != b2) boundary[i] |= (1 << j);
    }
  for ((i) = 0; (i) < (int)((1 << Y)); (i)++) dp[0][i] = (1ll << 60);
  dp[0][(1 << Y) - 1] = 0;
  for (x = 1; x < X; x++) {
    for ((i) = 0; (i) < (int)((1 << Y)); (i)++) dp[x][i] = (1ll << 60);
    for ((i) = 0; (i) < (int)((1 << Y)); (i)++) xsum[i] = ysum[i] = 0;
    for ((i) = 0; (i) < (int)((1 << Y)); (i)++)
      for ((j) = 0; (j) < (int)(Y); (j)++)
        if (i & (1 << j)) xsum[i] += xcap[x - 1][j];
    for ((i) = 0; (i) < (int)((1 << Y)); (i)++)
      for ((j) = 0; (j) < (int)(Y); (j)++)
        if (boundary[i] & (1 << j)) ysum[i] += ycap[x][j];
    for ((i) = 0; (i) < (int)((1 << Y)); (i)++)
      for ((j) = 0; (j) < (int)((1 << Y)); (j)++) {
        long long tmp = dp[x - 1][i] + xsum[i ^ j] + ysum[j];
        if (tmp < dp[x][j]) dp[x][j] = tmp;
      }
  }
  long long ans = dp[X - 1][0];
  cout << ans << endl;
  return 0;
}
