#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int, int>P;

int b[50][50];
bool used[50];
int main() {
	int s, d;
	while (scanf("%d%d", &s, &d), s) {
		priority_queue<P, vector<P>, greater<P>>que;
		rep(i, s)rep(j, d) {
			int a; scanf("%d", &a);
			if(a)que.push(P(a, j));
		}
		rep(i, d)rep(j, d - i - 1) {
			scanf("%d", &b[i][i + j + 1]);
			if (!b[i][i + j + 1])b[i][i + j + 1] = INF;
			b[i + j + 1][i] = b[i][i + j + 1];
		}
		memset(used, 0, sizeof(used));
		int ans = 0;
		while (!que.empty()) {
			P p = que.top(); que.pop();
			if (used[p.second])continue;
			used[p.second] = true;
			ans += p.first;
			rep(i, d) {
				if (!used[i])que.push(P(b[p.second][i], i));
			}
		}
		printf("%d\n", ans);
	}
}