#include <bits/stdc++.h>
int c[105] = {};
int p[105][105] = {};
long long int dp[105][105][105] = {};
int m;
inline long long int minimum(long long int a, long long int b) {
  return (a < b ? a : b);
}
long long int mcost(int n, int b, int last) {
  if (n == -1 && b == 0)
    return 0;
  else if (n == -1)
    return 1000000000000000000LL;
  else if (b < 0)
    return 1000000000000000000LL;
  else if (dp[n][b][last] == -1) {
    dp[n][b][last] = 1000000000000000000LL;
    if (c[n] == 0) {
      for (int j = 1; j <= m; j++) {
        if (j == last)
          dp[n][b][last] =
              minimum(dp[n][b][last], p[n][j] + mcost(n - 1, b, j));
        else
          dp[n][b][last] =
              minimum(dp[n][b][last], p[n][j] + mcost(n - 1, b - 1, j));
      }
    } else {
      if (c[n] != last)
        dp[n][b][last] = minimum(dp[n][b][last], mcost(n - 1, b - 1, c[n]));
      else
        dp[n][b][last] = minimum(dp[n][b][last], mcost(n - 1, b, c[n]));
    }
  }
  return dp[n][b][last];
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  int n, b;
  std::cin >> n >> m >> b;
  for (int i = 0; i < n; i++) std::cin >> c[i];
  for (int i = 0; i < n; i++)
    for (int j = 1; j <= m; j++) std::cin >> p[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= m; k++) dp[i][j][k] = -1;
  if (b > n)
    std::cout << -1 << '\n';
  else
    std::cout << (mcost(n - 1, b, 0) == 1000000000000000000LL
                      ? -1
                      : mcost(n - 1, b, 0))
              << '\n';
}
