#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long c[110];
long long p[110][110];
long long dp[110][110][110];
long long solve(long long i, long long j, long long kk) {
  if (kk == -1) return 9e18;
  if (i == -1) {
    if (kk == 0) return 0;
    return 9e18;
  }
  if (dp[i][j][kk] != -1) return dp[i][j][kk];
  long long ans = 9e18;
  if (c[i] != 0)
    ans = min(ans, solve(i - 1, c[i], kk - (c[i] != j)));
  else {
    for (long long cc = 1; cc <= m; cc++)
      ans = min(ans, p[i][cc - 1] + solve(i - 1, cc, kk - (cc != j)));
  }
  return dp[i][j][kk] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int Y = 1;
  while (Y--) {
    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];
      }
    }
    memset(dp, -1, sizeof(dp));
    long long ans = solve(n - 1, 0, k);
    if (ans == 9e18)
      cout << "-1" << '\n';
    else
      cout << ans << '\n';
  }
}
