#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int memo[100];
bool chk[100];
int sd[50][100];
int dd[100][100];

int main(){
  int s,d;
  while((s = getInt()) + (d = getInt())){
    REP(i,s) REP(j,d) sd[i][j] = getInt();
    REP(i,d) REP(j,d-i-1) dd[i][i+j+1] = dd[i+j+1][i] = getInt();
    REP(i,d){
      memo[i] = INT_MAX;
      chk[i] = false;
    }

    //puts("sd"); REP(i,s){ REP(j,d) printf("%d ",sd[i][j]); puts("");}
    //puts("dd"); REP(i,d){ REP(j,d) printf("%d ",dd[i][j]); puts("");}

    typedef pair<int,int> data;
    priority_queue<data,vector<data>,greater<data> > pq;
    REP(i,d){
      int pp = INT_MAX;
      REP(j,s) if(sd[j][i])
        pp = min(pp, sd[j][i]);
      pq.push(mp(pp,i));
      memo[i] = pp;
    }

    int cnt = 0;
    int ans = 0;
    while(cnt < d){
      data dt = pq.top();
      int  cost = dt.f;
      int  pos  = dt.s;
      pq.pop();

      if(chk[pos]) continue;
      chk[pos] = true;
      cnt++;
      ans += cost;

      REP(i,d) if(i != pos && !chk[i]){
        int cc = dd[i][pos];
        if(cc && cc < memo[i]){
          memo[i] = cc;
          pq.push(mp(cc, i));
        }
      }
    }
    print(ans);
  }
  return 0;
}