#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

typedef pair<int,int> P;

vector<P> G[100];
int s,d;
bool v[100];

int prim(void){
  int res = 0;
  for(int i=0;i<=s+d;i++)v[i] = false;
  v[0] = v[s+d] = true;
  priority_queue<P,vector<P>,greater<P> > q;
  
  for(int i=0;i<(int)G[0].size();i++){
    P next = G[0][i];
    if(v[next.second])continue;
    q.push(next);
  }

  for(int i=0;i<(int)G[s+d].size();i++){
    P next = G[s+d][i];
    if(v[next.second])continue;
    q.push(next);
  }
  
  while(q.size()){
    P p = q.top(); q.pop();
    int now = p.second;    

    if(v[now])continue;
    v[now] = true;
    res += p.first;

    for(int i=0;i<(int)G[now].size();i++){
      P next = G[now][i];
      if(v[next.second])continue;
      q.push(next);
    }
  }

  return res;
}

int main(){
  while(cin >> s >> d, s||d){
    for(int i=0;i<=s+d;i++)G[i].clear();

    int tmp;
    for(int i=0;i<s;i++)
      for(int j=0;j<d;j++){
	cin >> tmp;
	if(!tmp)tmp = 100000000;
	G[i].push_back(P(tmp,s+j));
	G[s+j].push_back(P(tmp,i));
      }
    
    for(int i=0;i<d;i++)
      for(int j=i+1;j<d;j++){
	cin >> tmp;
	if(!tmp)tmp = 100000000;
	G[s+i].push_back(P(tmp,s+j));
	G[s+j].push_back(P(tmp,s+i));
      }

    for(int i=0;i<s;i++){
      G[s+d].push_back(P(0,i));
    }

    cout << prim() << endl;
  }
}