#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

const int NODE = 51;
const int INF = (1<<25);

int CHOT[NODE][NODE]; // cost from hot springs to districts
int CDIS[NODE][NODE]; // cost between districts
int S,D;
int mincos[NODE];

void input(){
  fill(mincos,mincos+NODE,INF);

  for(int i = 0; i < S; i++)
    for(int j = 0; j < D; j++) {
      cin >> CHOT[i][j];
      if(CHOT[i][j] == 0) CHOT[i][j] = INF;
      mincos[j] = min(mincos[j],CHOT[i][j]);
    }

  for(int i = 0; i < D; i++)
    for(int j = 1; j < D-i; j++){
      int in;
      cin >> in;
      if(in == 0) CDIS[i][i+j] = CDIS[i+j][i] = INF;
      else CDIS[i][i+j] = CDIS[i+j][i] = in;
    }
}

void prim(){
  bool used[NODE];
  memset(used,false,sizeof(used));

  int res = 0;
  while(1){
    int v = -1;
    
    for(int i = 0; i < D; i++)
      if(!used[i] && (v == -1 || mincos[i] < mincos[v])) v = i;

    //   cout << "v " << v << endl;
    if(v == -1) break;
    used[v] = true;
    res += mincos[v];

    for(int i = 0; i < D; i++)
      mincos[i] = min(mincos[i],CDIS[v][i]);
  }
  cout << res << endl;
}

int main(){

  while(cin >> S >> D && S+D){
    input();
    prim();
  }
  
  return 0;
}