#include <bits/stdc++.h>
const int maxn = 1e2 + 10;
const int dis[4][2] = {{0, 1}, {-1, 0}, {0, -1}, {1, 0}};
using namespace std;
long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }
long long qpow(long long p, long long q) {
  long long f = 1;
  while (q) {
    if (q & 1) f = f * p % 1000000007;
    p = p * p % 1000000007;
    q >>= 1;
  }
  return f;
}
int n, m, k, t, q, co[maxn][maxn], c[maxn];
long long dp[maxn][maxn][maxn];
int main() {
  int i, j;
  for (i = 0; i <= 100; i++)
    for (j = 0; j <= 100; j++)
      for (k = 0; k <= 100; k++) dp[i][j][k] = 1e18;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &co[i][j]);
  i = 1;
  if (i == 1) {
    if (c[i])
      dp[1][c[i]][1] = 0;
    else {
      for (j = 1; j <= m; j++) dp[1][j][1] = co[1][j];
    }
  }
  for (i = 2; i <= n; i++) {
    if (c[i]) {
      for (j = 1; j <= m; j++)
        for (k = 1; k <= 100; k++) {
          if (j == c[i])
            dp[i][j][k] = min(dp[i - 1][j][k], dp[i][j][k]);
          else
            dp[i][c[i]][k] = min(dp[i - 1][j][k - 1], dp[i][c[i]][k]);
        }
    } else {
      for (j = 1; j <= m; j++)
        for (k = 1; k <= 100; k++)
          for (t = 1; t <= m; t++) {
            dp[i][j][k] =
                min(dp[i][j][k], t == j ? dp[i - 1][t][k] + co[i][j]
                                        : dp[i - 1][t][k - 1] + co[i][j]);
          }
    }
  }
  long long mi = 1e18;
  for (i = 1; i <= m; i++) mi = min(dp[n][i][q], mi);
  printf("%lld\n", mi == 1e18 ? -1 : mi);
  return 0;
}
