#include <bits/stdc++.h>
using namespace std;
long long int z = 100000000000000007;
int main() {
  long long int n, m, k;
  cin >> n >> m >> k;
  vector<long long int> colour(n + 1, -1);
  for (int i = 1; i <= n; i++) {
    long long int temp;
    cin >> temp;
    colour[i] = temp;
  }
  vector<vector<long long int> > cost(n + 1, vector<long long int>(m + 1, -1));
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      long long int temp;
      cin >> temp;
      cost[i][j] = temp;
    }
  }
  vector<vector<vector<long long int> > > dp(
      n + 1,
      vector<vector<long long int> >(m + 1, vector<long long int>(k + 1, z)));
  if (colour[1] != 0)
    dp[1][colour[1]][1] = 0;
  else {
    for (long long int i = 1; i <= m; i++) {
      dp[1][i][1] = cost[1][i];
    }
  }
  for (long long int p = 2; p <= n; p++) {
    for (long long int q = 1; q <= m; q++) {
      for (long long int r = 1; r <= k; r++) {
        long long int min = z;
        if (colour[p] == 0) {
          for (long long int s = 1; s <= m; s++) {
            if (s == q) {
              if (dp[p - 1][s][r] + cost[p][q] < min)
                min = dp[p - 1][s][r] + cost[p][q];
            } else {
              if (dp[p - 1][s][r - 1] + cost[p][q] < min)
                min = dp[p - 1][s][r - 1] + cost[p][q];
            }
          }
          dp[p][q][r] = min;
        } else {
          if (colour[p] != q) {
            dp[p][q][r] = z;
          } else {
            long long int min = z;
            for (int s = 1; s <= m; s++) {
              if (s == colour[p]) {
                if (dp[p - 1][s][r] < min) min = dp[p - 1][s][r];
              } else {
                if (dp[p - 1][s][r - 1] < min) min = dp[p - 1][s][r - 1];
              }
            }
            dp[p][q][r] = min;
          }
        }
      }
    }
  }
  long long int ans = z;
  for (int i = 1; i <= m; i++) {
    if (ans > dp[n][i][k]) ans = dp[n][i][k];
  }
  if (ans < z)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
