#include <bits/stdc++.h>
using namespace std;
struct IO {
  IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
} _;
long long n, m, len, k, t, a, b;
long long c[101];
long long p[101][101];
long long dp[101][101][101];
long long rec(long long idx, long long col, long long cnt) {
  long long &ret = dp[idx][col][cnt];
  if (ret != -1) return ret;
  if (idx + 1 >= n) {
    if (cnt + 1 == k)
      return 0;
    else
      return 10000000000007LL;
  } else if (c[idx + 1] == 0) {
    long long minz = 10000000000007LL;
    for (long long i = 1; i <= m; i++) {
      minz = min(minz, p[idx + 1][i - 1] + rec(idx + 1, i, cnt + (i != col)));
    }
    return ret = minz;
  } else {
    return ret = rec(idx + 1, c[idx + 1], cnt + (c[idx + 1] != col));
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) cin >> c[i];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) cin >> p[i][j];
  if (c[0] != 0) {
    long long ans = rec(0, c[0], 0);
    if (ans >= 10000000000007LL)
      cout << -1 << "\n";
    else
      cout << ans << "\n";
    return 0;
  }
  long long minz = 10000000000007LL;
  for (long long i = 1; i <= m; i++)
    minz = min(minz, p[0][i - 1] + rec(0, i, 0));
  if (minz >= 10000000000007LL)
    cout << -1 << "\n";
  else
    cout << minz << "\n";
  return 0;
}
