#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int MAX = 51;
int dis_d[MAX][MAX], in, s, d, G[MAX][MAX], ans;
int min_d[MAX];
bool used[MAX];
void prim() {
  for (int i = 0; i < d; i++) {
    min_d[i] = INF;
    used[i] = false;
  }
  min_d[0] = 0;
  int res = 0;
  while (true) {
    int v = -1;
    for (int u = 0; u < d; u++) {
      if (!used[u] && (v == -1 || min_d[u] < min_d[v])) v = u;
    }
    if (v == -1) break;
    used[v] = true;
    res += min_d[v];
    for (int u = 0; u < d; u++) {
      if (u - v < s)
        min_d[u] = min(min_d[u], G[u - v][v] + dis_d[v][u]);
      else
        min_d[u] = min(min_d[u], dis_d[v][u]);
    }
  }
  ans = res - 1;
}
int main() {
  while (cin >> s >> d, s + d) {
    memset(G, 0, sizeof(G));
    for (int i = 0; i < s; i++) {
      for (int j = 0; j < d; j++) {
        cin >> G[i][j];
      }
    }
    memset(dis_d, 0, sizeof(dis_d));
    for (int i = 0; i < d - 1; i++) {
      for (int j = i + 1; j < d; j++) {
        cin >> in;
        dis_d[i][j] = dis_d[j][i] = in;
      }
    }
    prim();
    cout << ans << endl;
  }
  return 0;
}
