#include <bits/stdc++.h>
using namespace std;
long long dp[105][105][105];
long long v[105][105];
int rec[105];
int n, m, k;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &rec[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%I64d", &v[i][j]);
  memset(dp, -1, sizeof(dp));
  if (rec[1] == 0) {
    for (int l = 1; l <= m; l++) {
      dp[1][1][l] = v[1][l];
    }
  } else {
    dp[1][1][rec[1]] = 0;
  }
  for (int i = 2; i <= n; i++) {
    if (rec[i]) {
      for (int j = 1; j <= k; j++)
        for (int l = 1; l <= m; l++) {
          if (l == rec[i]) {
            if (dp[i - 1][j][l] == -1) continue;
            if (dp[i][j][rec[i]] == -1)
              dp[i][j][rec[i]] = dp[i - 1][j][l];
            else
              dp[i][j][rec[i]] = min(dp[i][j][rec[i]], dp[i - 1][j][l]);
          } else {
            if (dp[i - 1][j - 1][l] == -1) continue;
            if (dp[i][j][rec[i]] == -1)
              dp[i][j][rec[i]] = dp[i - 1][j - 1][l];
            else
              dp[i][j][rec[i]] = min(dp[i][j][rec[i]], dp[i - 1][j - 1][l]);
          }
        }
    } else
      for (int j = 1; j <= k; j++) {
        for (int l = 1; l <= m; l++) {
          if (dp[i - 1][j][l] != -1) dp[i][j][l] = dp[i - 1][j][l];
          for (int p = 1; p <= m; p++) {
            if (p == l) {
              continue;
            } else {
              if (dp[i - 1][j - 1][p] == -1) continue;
              if (dp[i][j][l] == -1)
                dp[i][j][l] = dp[i - 1][j - 1][p];
              else
                dp[i][j][l] = min(dp[i][j][l], dp[i - 1][j - 1][p]);
            }
          }
          if (dp[i][j][l] != -1) dp[i][j][l] += v[i][l];
        }
      }
  }
  long long ans = -1;
  for (int i = 1; i <= m; i++) {
    if (dp[n][k][i] == -1)
      continue;
    else if (ans == -1)
      ans = dp[n][k][i];
    else
      ans = min(ans, dp[n][k][i]);
  }
  printf("%I64d\n", ans);
}
