#include <bits/stdc++.h>
using namespace std;
long long mat[105][105];
int v[105];
const long long inf = (1LL << 45);
long long dp[104][105][105];
int n, m, k;
long long solve(int pos, int last, int qt) {
  if (qt > k) return inf;
  if (pos == n) {
    if (qt == k)
      return 0;
    else
      return inf;
  }
  long long &ans = dp[pos][last][qt];
  if (ans != -1) return ans;
  ans = inf;
  if (v[pos] != 0) {
    return ans = solve(pos + 1, v[pos], qt + (last != v[pos]));
  }
  for (int i = 1; i <= m; i++) {
    ans = min(ans, solve(pos + 1, i, qt + (last != i)) + mat[pos][i]);
  }
  return ans;
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%lld", &mat[i][j]);
    }
  }
  memset(dp, -1, sizeof(dp));
  long long ans = solve(0, 0, 0);
  if (ans >= inf) ans = -1;
  printf("%lld\n", ans);
  return 0;
}
