#include <bits/stdc++.h>
using namespace std;
int s, d, a[50][50];
int F() {
  bool f[50] = {0};
  int r = 0, i;
  pair<int, int> p;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  q.push(pair<int, int>(0, 0));
  while (!q.empty()) {
    p = q.top();
    q.pop();
    if (f[p.second]) continue;
    f[p.second] = 1;
    r += p.first;
    for (i = 0; i < s + d; ++i)
      if (a[p.second][i] != INT_MAX) q.push(pair<int, int>(a[p.second][i], i));
  }
  return r;
}
int main() {
  int i, j, x;
  while (scanf("%d%d", &s, &d), s) {
    for (i = 0; i < s; ++i) {
      for (j = 0; j < d; ++j)
        scanf("%d", &x), a[i][s + j] = a[s + j][i] = (x > 0 ? x : INT_MAX);
      for (j = 0; j < s; ++j) a[i][j] = 0, a[i][i] = INT_MAX;
    }
    for (i = 0; i < d; ++i)
      for (j = 0; j < d; ++j) a[i + s][j + s] = INT_MAX;
    for (i = 0; i < d - 1; ++i)
      for (j = 0; j < d - i - 1; ++j)
        scanf("%d", &x), a[s + i + j + 1][s + i] = a[s + i][s + i + j + 1] =
                             (x > 0 ? x : INT_MAX);
    printf("%d\n", F());
  }
  return 0;
}
