#include <bits/stdc++.h>
using namespace std;
int c[110];
int n, m, k, y, beauty, foo, sz;
bool ze;
long long mat[110][110];
long long dp[110][110][110];
long long solve(int pos, int rem, int pc) {
  if (pos == n) {
    if (rem == 0)
      return 0;
    else if (rem > 0)
      return 10000000000000;
  }
  if (rem < 0) return 10000000000000;
  if (dp[pos][rem][pc] != -1) return dp[pos][rem][pc];
  int c1 = -1;
  if (pos - 1 >= 0) c1 = c[pos - 1];
  if (c[pos] != 0) {
    if (c[pos] != c1)
      dp[pos][rem][pc] = solve(pos + 1, rem - 1, c[pos]);
    else
      dp[pos][rem][pc] = solve(pos + 1, rem, c[pos]);
  } else {
    dp[pos][rem][pc] = 10000000000000;
    for (int i = 1; i <= m; i++) {
      c[pos] = i;
      if (c[pos] != c1) {
        dp[pos][rem][pc] = min(dp[pos][rem][pc],
                               mat[pos][i] + solve(pos + 1, rem - 1, c[pos]));
      } else {
        dp[pos][rem][pc] =
            min(dp[pos][rem][pc], mat[pos][i] + solve(pos + 1, rem, c[pos]));
      }
    }
    c[pos] = 0;
  }
  return dp[pos][rem][pc];
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    if (c[i] == 0) ze = true;
    if (i == 0) y = c[i];
    if (i != 0 && c[i] != y) {
      if (y != 0) beauty++;
      y = c[i];
    }
  }
  if (c[n - 1] != 0) beauty++;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) scanf("%lld", &mat[i][j]);
  }
  if (beauty > k)
    printf("-1\n");
  else if (!ze && beauty == k)
    printf("0\n");
  else {
    memset(dp, -1, sizeof dp);
    long long ans = solve(0, k, 0);
    if (ans >= 10000000000000)
      printf("-1\n");
    else
      printf("%lld\n", ans);
  }
  return 0;
}
