#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j;
  while (scanf("%d %d", &i, &j) == 2, i && j) {
    map<int, map<int, int> > graph;
    for (int x = 0; x < i; ++x) {
      for (int y = 0; y < j; ++y) {
        int w;
        scanf("%d", &w);
        if (w != 0) graph[x][i + y] = w;
      }
    }
    for (int x = 0; x < j; ++x) {
      for (int y = x + 1; y < j; ++y) {
        int w;
        scanf("%d", &w);
        if (w != 0) graph[i + x][y + i] = w;
      }
    }
    int sol[j + i];
    for (int x = 0; x < j + i; ++x) {
      sol[x] = 1000;
    }
    for (int w = 0; w < i; ++w) {
      map<int, int> tmp = graph[w];
      for (map<int, int>::iterator it = tmp.begin(); it != tmp.end(); ++it) {
        if (sol[it->first] > it->second) {
          sol[it->first] = it->second;
        }
      }
    }
    queue<int> nodes;
    nodes.push(i);
    while (!nodes.empty()) {
      int next = nodes.front();
      nodes.pop();
      map<int, int> tmp = graph[next];
      for (map<int, int>::iterator it = tmp.begin(); it != tmp.end(); ++it) {
        if (sol[it->first] > it->second) {
          sol[it->first] = it->second;
        }
        nodes.push(it->first);
      }
    }
    sol[0] = 0;
    for (int x = i; x < j + i; ++x) {
      sol[0] += sol[x];
    }
    cout << sol[0] << endl;
  }
  return 0;
}
