#include <bits/stdc++.h>
using namespace std;
long long dp[105][105][105];
long long va[105][105];
int n, m, k;
int a[105];
long long solve() {
  if (a[1])
    dp[1][a[1]][1] = 0;
  else {
    for (int i = 1; i <= m; i++) dp[1][i][1] = va[1][i];
  }
  for (int i = 2; i <= n; i++)
    if (a[i]) {
      for (int j = 1; j <= m; j++)
        for (int k = 1; k < i; k++) {
          if (dp[i - 1][j][k] == -1) continue;
          if (j == a[i]) {
            if (dp[i][j][k] == -1) dp[i][j][k] = dp[i - 1][j][k];
            dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][k]);
          } else {
            if (dp[i][a[i]][k + 1] == -1) dp[i][a[i]][k + 1] = dp[i - 1][j][k];
            dp[i][a[i]][k + 1] = min(dp[i][a[i]][k + 1], dp[i - 1][j][k]);
          }
        }
    } else {
      for (int j = 1; j <= m; j++)
        for (int k = 1; k < i; k++) {
          if (dp[i - 1][j][k] == -1) continue;
          for (int to = 1; to <= m; to++) {
            if (to == j) {
              dp[i][to][k] =
                  min(dp[i - 1][j][k] + va[i][to],
                      dp[i][to][k] == -1 ? dp[i - 1][j][k] + va[i][to]
                                         : dp[i][to][k]);
            } else {
              dp[i][to][k + 1] =
                  min(dp[i - 1][j][k] + va[i][to],
                      dp[i][to][k + 1] == -1 ? dp[i - 1][j][k] + va[i][to]
                                             : dp[i][to][k + 1]);
            }
          }
        }
    }
  long long ans = -1;
  for (int i = 1; i <= m; i++)
    if (dp[n][i][k] != -1) {
      if (ans == -1)
        ans = dp[n][i][k];
      else
        ans = min(dp[n][i][k], ans);
    }
  return ans;
}
int main() {
  int i, j;
  while (~scanf("%d%d%d", &n, &m, &k)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cin >> va[i][j];
    memset(dp, -1, sizeof(dp));
    cout << solve() << endl;
  }
  return 0;
}
