#include <bits/stdc++.h>
using namespace std;
void Mo35();
const long long OO = 1e16;
long long n, m, k;
long long treeColor[105], colorAmount[105][105], dp[105][105][105];
long long minAmount(long long indx, long long pre, long long groups) {
  if (indx == n) return (groups == k ? 0 : OO);
  long long &ret = dp[indx][pre][groups];
  if (~ret) return ret;
  ret = OO;
  if (treeColor[indx]) {
    if (treeColor[indx] == pre)
      ret = min(ret, minAmount(indx + 1, pre, groups));
    else
      ret = min(ret, minAmount(indx + 1, treeColor[indx], groups + 1));
  } else {
    for (long long i = 1; i <= m; ++i)
      if (colorAmount[i]) {
        if (i == pre)
          ret = min(ret, colorAmount[indx][i] + minAmount(indx + 1, i, groups));
        else
          ret = min(ret,
                    colorAmount[indx][i] + minAmount(indx + 1, i, groups + 1));
      }
  }
  return ret;
}
void test() {
  cin >> n >> m >> k;
  for (long long i = 0; i < n; ++i) cin >> treeColor[i];
  for (long long i = 0; i < n; ++i)
    for (long long j = 1; j <= m; ++j) {
      cin >> colorAmount[i][j];
    }
  memset(dp, -1, sizeof(dp));
  long long ans = minAmount(0, 0, 0);
  cout << (ans == OO ? -1 : ans);
}
int main() {
  Mo35();
  int cases = 1;
  while (cases--) {
    test();
  }
  return 0;
}
void Mo35() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
