#define PRIM_NODE_MAX 100
#define INF 1e9
int prim(int n,int cost[][PRIM_NODE_MAX]){
	int determined[PRIM_NODE_MAX]={0};
	int undeterminednodes=n;
	int mincost[PRIM_NODE_MAX],currminnode,minnode,minnodecost,totalcost=0;
	int i;
	
	// initialize mincost
	for(i=0;i<n;i++){
		mincost[i]=INF;
	}
	// determine node 0
	currminnode=0;
	minnodecost=0;

	for(;undeterminednodes--;){
		// the node is determined
		determined[currminnode]=1;
		totalcost+=minnodecost;

		minnodecost=INF;
		for(i=0;i<n;i++){
			if(!determined[i]){
				// update mincost around the currminnode
				if(cost[currminnode][i]<mincost[i])
					mincost[i]=cost[currminnode][i];
				// select the nearest undetermined node
				if(mincost[i]<minnodecost){
					minnode=i;
					minnodecost=mincost[i];
				}
			}
		}
		currminnode=minnode;
	}
	return totalcost;
}
s,d,C[100][100];
main(){
	int i,j,v;
	for(;scanf("%d%d",&s,&d)*s;){
		memset(C,0,sizeof(C));
		for(j=0;j<s;j++){
			for(i=0;i<d;i++){
				scanf("%d",&v);
				C[j][s+i]=C[s+i][j]=v?v:INF;
			}
		}
		for(j=0;j<d-1;j++){
			for(i=0;i<d-j-1;i++){
				scanf("%d",&v);
				C[s+j][s+j+1+i]=C[s+j+1+i][s+j]=v?v:INF;
			}
		}
		printf("%d\n",prim(s+d,C));
	}
}