#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  int m, n;
  while (cin >> m >> n, m || n) {
    priority_queue<pair<int, pair<int, int> >,
                   vector<pair<int, pair<int, int> > >,
                   greater<pair<int, pair<int, int> > > >
        b;
    for (i = 0; i < m; ++i) {
      for (j = 0; j < n; ++j) {
        int p;
        cin >> p;
        if (p) b.push(make_pair(p, make_pair(n + i, j)));
      }
    }
    for (i = n - 1; i > 0; --i) {
      for (j = 0; j < i; ++j) {
        int p;
        cin >> p;
        if (p) b.push(make_pair(p, make_pair(n - i - 1, n - i + j)));
      }
    }
    int c[100];
    memset(c, -1, sizeof(c));
    for (i = 0; i < n; ++i) c[i] = i;
    int sm = 0;
    for (;;) {
      for (i = 1; i < m + n; ++i) {
        if (c[i - 1] != c[i]) break;
      }
      if (i >= m + n) break;
      int p, q, r;
      p = b.top().first;
      q = b.top().second.first;
      r = b.top().second.second;
      b.pop();
      if (q == r) continue;
      sm += p;
      for (i = 0; i < m + n; ++i) {
        if (i != q && c[i] == c[q]) c[i] = c[r];
      }
      c[q] = c[r];
    }
    cout << sm << endl;
  }
  return 0;
}
