#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
typedef struct _edge {
  int to, cost;
  _edge(int ito, int icost) : to(ito), cost(icost){};
} edge;
vector<edge> E[60];
int s, d;
bool used[50];
int prim() {
  memset(used, 0, sizeof(used));
  priority_queue<pair<int, int> > Q;
  Q.push(make_pair(0, 0));
  int ret = 0;
  while (!Q.empty()) {
    int ccost = -Q.top().first, from = Q.top().second;
    Q.pop();
    if (used[from]) continue;
    used[from] = true;
    ret += ccost;
    for (int i = 0; i < (int)E[from].size(); ++i) {
      int to = E[from][i].to, cost = E[from][i].cost;
      if (used[to]) continue;
      Q.push(make_pair(-cost, to));
    }
  }
  return ret;
}
int main() {
  while (cin >> s >> d, s | d) {
    for (int i = 0; i < (int)s + d; ++i) E[i].clear();
    for (int i = 0; i < (int)s; ++i) {
      for (int j = 0; j < (int)d; ++j) {
        int co;
        cin >> co;
        if (!co) continue;
        E[i].push_back(edge(j + s, co));
      }
    }
    for (int i = 0; i < (int)d - 1; ++i) {
      for (int j = 0; j < (int)d - i - 1; ++j) {
        int co;
        cin >> co;
        if (!co) continue;
        int to = i + j + 1 + s;
        E[i + s].push_back(edge(to, co));
        E[to].push_back(edge(i + s, co));
      }
    }
    for (int i = 0; i < (int)s; ++i) {
      for (int j = 0; j < (int)i; ++j) {
        E[i].push_back(edge(j, 0));
        E[j].push_back(edge(i, 0));
      }
    }
    cout << prim() << endl;
  }
}
