#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const double eps = 1e-10;
const long long N = 2e5 + 7;
const long long MOD = 1e9 + 7;
long long pw(long long b, long long p) {
  b %= MOD;
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<long long> c(n + 1);
  for (long long i = 1; i < n + 1; i++) cin >> c[i];
  long long dp[n + 1][k + 1][m + 1];
  for (long long i = 0; i < n + 1; i++) {
    for (long long j = 0; j < k + 1; j++) {
      for (long long p = 0; p < m + 1; p++) {
        dp[i][j][p] = 0x3f3f3f3f3f3f3f3fLL;
      }
    }
  }
  long long cost[n + 1][m + 1];
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      cin >> cost[i][j];
    }
  }
  if (!c[1]) {
    for (long long i = 1; i < m + 1; i++) {
      dp[1][1][i] = cost[1][i];
    }
  } else {
    dp[1][1][c[1]] = 0;
  }
  for (long long i = 2; i < n + 1; i++) {
    for (long long j = 1; j < k + 1; j++) {
      if (!c[i]) {
        for (long long p = 1; p < m + 1; p++) {
          dp[i][j][p] = min(dp[i][j][p], dp[i - 1][j][p] + cost[i][p]);
          for (long long q = 1; q < m + 1; q++) {
            if (q != p)
              dp[i][j][p] = min(dp[i][j][p], dp[i - 1][j - 1][q] + cost[i][p]);
          }
        }
      } else {
        dp[i][j][c[i]] = min(dp[i][j][c[i]], dp[i - 1][j][c[i]]);
        for (long long p = 1; p < m + 1; p++) {
          if (c[i] != p) {
            dp[i][j][c[i]] = min(dp[i][j][c[i]], dp[i - 1][j - 1][p]);
          }
        }
      }
    }
  }
  long long ans = 0x3f3f3f3f3f3f3f3fLL;
  for (long long i = 1; i < m + 1; i++) {
    ans = min(ans, dp[n][k][i]);
  }
  if (ans >= 0x3f3f3f3f3f3f3f3fLL) ans = -1;
  cout << ans;
  return 0;
}
