#include <bits/stdc++.h>
using namespace std;
const long long oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
const int maxn = 110;
long long cur_color[maxn];
long long cost[maxn][maxn];
long long dp[maxn][maxn][maxn];
set<pair<long long, long long> > memo[maxn][maxn];
void update(long long t, long long c, long long k) {
  memo[t][k].insert({-dp[t][c][k], c});
  while (memo[t][k].size() > 2) {
    memo[t][k].erase(memo[t][k].begin());
  }
}
long long ndp(long long t, long long c, long long k) {
  long long ans = oo;
  for (auto p : memo[t][k])
    if (p.second != c) ans = min(ans, -p.first);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; ++i) {
    cin >> cur_color[i];
  }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) cin >> cost[i][j];
  }
  memset(dp, oo, sizeof dp);
  for (long long i = 1; i <= m; ++i) dp[0][i][1] = 0;
  for (long long t = 1; t <= n; ++t) {
    if (cur_color[t] == 0) {
      for (long long c = 1; c <= m; ++c) {
        for (long long kk = 1; kk <= k; ++kk) {
          dp[t][c][kk] =
              min(dp[t - 1][c][kk], ndp(t - 1, c, kk - 1)) + cost[t][c];
          update(t, c, kk);
        }
      }
    } else {
      long long c = cur_color[t];
      for (long long kk = 1; kk <= k; ++kk) {
        dp[t][c][kk] = min(dp[t - 1][c][kk], ndp(t - 1, c, kk - 1));
        update(t, c, kk);
      }
    }
  }
  long long ans = oo;
  for (long long c = 1; c <= m; ++c) ans = min(ans, dp[n][c][k]);
  if (ans == oo)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
  return 0;
}
