#include <bits/stdc++.h>
using namespace std;
int main() {
  int s, d;
  while (scanf("%d %d", &s, &d) == 2, s || d) {
    int sol[d];
    for (int x = 0; x < d; x++) sol[x] = 1000;
    for (int x = 0; x < s; ++x) {
      for (int y = 0; y < d; ++y) {
        int j;
        scanf("%d", &j);
        if (j != 0) {
          sol[y] = min(sol[y], j);
        }
      }
    }
    for (int x = 0; x < d - 1; ++x) {
      for (int y = 0; y < d - x - 1; ++y) {
        int j;
        scanf("%d", &j);
        if (j != 0) {
          sol[x + y + 1] = min(sol[x + y + 1], j);
        }
      }
    }
    int tot = 0;
    for (int x = 0; x < d; ++x) tot += sol[x];
    cout << tot << endl;
  }
  return 0;
}
