#include <bits/stdc++.h>
using namespace std;
const long long hell = 1e9 + 7;
long long inf = 1e14;
const long long N = 1e5 + 9;
bool prime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long power(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long a[105][105];
long long n, m, k;
long long col[105];
long long dp[105][105][105];
long long solve(long long i, long long prev, long long curr_k) {
  if (i == n) {
    if (curr_k == 0)
      return 0;
    else
      return inf;
  }
  if (curr_k < 0) return inf;
  if (dp[i][prev][curr_k] != -1) return dp[i][prev][curr_k];
  long long ans = inf;
  if (col[i] != 0) {
    if (col[i] == prev)
      ans = min(ans, solve(i + 1, col[i], curr_k));
    else
      ans = min(ans, solve(i + 1, col[i], curr_k - 1));
  } else {
    for (long long j = 1; j <= m; j++) {
      if (j != prev)
        ans = min(ans, a[i][j] + solve(i + 1, j, curr_k - 1));
      else
        ans = min(ans, a[i][j] + solve(i + 1, prev, curr_k));
    }
  }
  return dp[i][prev][curr_k] = ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    for (long long i = 0; i < 105; i++)
      for (long long j = 0; j < 105; j++)
        for (long long k = 0; k < 105; k++) dp[i][j][k] = -1;
    cin >> n >> m >> k;
    for (long long i = 0; i < n; i++) cin >> col[i];
    for (long long i = 0; i < n; i++) {
      for (long long j = 1; j <= m; j++) cin >> a[i][j];
    }
    long long ans = inf;
    ans = solve(0, 104, k);
    if (ans == inf)
      cout << -1 << "\n";
    else
      cout << ans << "\n";
  }
  return 0;
}
