#include<cstdio>
#include<map>
#include<queue>
#include<functional>
#include<climits>
using namespace std;
int s,d,a[100][100];
int F()
{
	bool f[100]={0};
	int r=0,i;
	typedef pair<int,int>P;
	P p;
	priority_queue<P,vector<P>,greater<P> >q;
	q.push(P(0,0));
	while(!q.empty())
	{
		p=q.top();q.pop();
		if(f[p.second])continue;
		f[p.second]=1;
		r+=p.first;
		for(i=0;i<s+d;++i)if(a[p.second][i]!=INT_MAX)q.push(P(a[p.second][i],i));
	}
	return r;
}
int main()
{
	int i,j,x;
	while(scanf("%d%d",&s,&d),s)
	{
		for(i=0;i<s;++i)
		{
			for(j=0;j<d;++j)scanf("%d",&x),a[i][s+j]=a[s+j][i]=(x>0?x:INT_MAX);
			for(j=0;j<s;++j)a[i][j]=0,a[i][i]=INT_MAX;
		}
		for(i=0;i<d;++i)for(j=0;j<d;++j)a[i+s][j+s]=INT_MAX;
		for(i=0;i<d-1;++i)for(j=0;j<d-i-1;++j)scanf("%d",&x),a[s+i+j+1][s+i]=a[s+i][s+i+j+1]=(x>0?x:INT_MAX);
		printf("%d\n",F());
	}
	return 0;
}