#include <bits/stdc++.h>
using namespace std;
int main() {
  for (int s, dd; cin >> s >> dd, s | dd;) {
    int d[100][100];
    fill(d[0], d[100], 1 << 30);
    for (int i = 0; i < s; i++) {
      for (int j = 0; j < s; j++) {
        d[i + dd][j + dd] = 0;
      }
    }
    for (int j = 0; j < s; j++) {
      for (int i = 0; i < dd; i++) {
        int cd;
        cin >> cd;
        if (cd) {
          d[i][dd + j] = d[dd + j][i] = cd;
        }
      }
    }
    for (int j = 0; j < dd - 1; j++) {
      for (int i = 0; i < dd - j - 1; i++) {
        int cd;
        cin >> cd;
        if (cd) {
          d[j][i + j + 1] = d[i + j + 1][i] = cd;
        }
      }
    }
    bool u[100] = {};
    int l = 0;
    int n[100];
    fill(n, n + 100, 1 << 30);
    n[dd] = 0;
    for (int i = 0; i < s + dd; i++) {
      int nm = 1 << 30;
      int x;
      for (int j = 0; j < s + dd; j++) {
        if (!u[j] && nm > n[j]) {
          x = j;
          nm = n[j];
        }
      }
      u[x] = true;
      l += n[x];
      for (int j = 0; j < s + dd; j++) {
        n[j] = min(n[j], d[x][j]);
      }
    }
    cout << l << endl;
  }
  return 0;
}
