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=s;j--;)for(i=d;i--;C[j][s+i]=C[s+i][j]=v?v:1e9)scanf("%d",&v);for(j=d-1;j--;)for(i=d-j-1;i--;C[s+j][s+j+1+i]=C[s+j+1+i][s+j]=v?v:1e9)scanf("%d",&v);memset(c,1,400);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;}}