S,C[100][100];main(s,d){for(;scanf("%d%d",&s,&d)*s;printf("%d\n",S)){int D[100]={S=0},u=s+d,c[100],x,p,m,i,j,v;memset(C,0,4e4);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:1e9;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:1e9;for(i=s+d;i--;)c[i]=1e9;for(x=m=0;u--;x=p)for(D[x]=1,S+=m,m=1e9,i=s+d;i--;)!D[i]?C[x][i]<c[i]?c[i]=C[x][i]:0,c[i]<m?m=c[p=i]:0:0;}}