#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int INF = INT_MAX / 4;

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	while ( true )
	{
		int s, d;
		cin >> s >> d;

		if ( !( s | d ) )
		{
			break;
		}
		
		VI distance( d, INF );
		REP( i, 0, s )
		{
			REP( j, 0, d )
			{
				int tmp;
				cin >> tmp;
				if ( tmp == 0 )
				{
					continue;
				}
				distance[j] = min( distance[j], tmp );
			}
		}

		vector< vector<PII> > G( d );
		REP( i, 0, d - 1 )
		{
			REP( j, 0, d - i - 1 )
			{
				int tmp;
				cin >> tmp;
				if ( tmp == 0 )
				{
					continue;
				}

				G[ i ].PB( MP( i + j + 1, tmp ) );
				G[ i + j + 1 ].PB( MP( i, tmp ) );
			}
		}

		priority_queue< PII, vector<PII>, greater<PII> > que;
		REP( i, 0, d )
		{
			if ( distance[i] == INF )
			{
				continue;
			}
			que.push( MP( distance[i], i ) );
		}

		vector<bool> used( d, false );
		int res = 0;
		while ( !que.empty() )
		{
			auto cur = que.top();
			que.pop();

			if ( used[ cur.snd ] || distance[ cur.snd ] < cur.fst )
			{
				continue;
			}

			res += cur.fst;
			used[ cur.snd ] = true;

			REP( i, 0, G[ cur.snd ].size() )
			{
				auto e = G[ cur.snd ][i];
				if ( distance[ e.fst ] <= e.snd )
				{
					continue;
				}
				distance[ e.fst ] = e.snd;
				que.push( MP( e.snd, e.fst ) );
			}
		}

		cout << res << endl;
	}

	return 0;
}