#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long c[109];
long long p[109][109];
long long dp[109][109][109];
long long f(long long prev, long long pos, long long div) {
  if (prev != 0 && dp[prev][pos][div] != -1) {
    return dp[prev][pos][div];
  }
  long long &ans = dp[prev][pos][div];
  if (pos == n && div == k) {
    ans = 0;
    return 0;
  }
  if (pos == n) {
    ans = 1e18;
    return 1e18;
  }
  ans = 1e18;
  if (c[pos] != 0) {
    if (prev == c[pos])
      ans = f(c[pos], pos + 1, div);
    else
      ans = f(c[pos], pos + 1, div + 1);
    return ans;
  }
  for (long long i = 1; i <= m; i++) {
    if (prev != i)
      ans = min(ans, (f(i, pos + 1, div + 1) + p[pos][i]));
    else
      ans = min(ans, (f(i, pos + 1, div) + p[pos][i]));
  }
  return ans;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) cin >> p[i][j];
  }
  for (int i = 0; i < 109; i++) {
    for (int j = 0; j < 109; j++) {
      for (int k = 0; k < 109; k++) dp[i][j][k] = -1;
    }
  }
  long long ans = f(0, 0, 0);
  if (ans == 1e18)
    cout << -1 << "\n";
  else
    cout << ans << "\n";
}
