#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int c[N] = {0};
int p[N][N] = {0};
long long dp[N][N][N] = {0};
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) cin >> c[i];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> p[i][j];
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    int beginColor = c[i] == 0 ? 1 : c[i];
    int endColor = c[i] == 0 ? m : c[i];
    for (int color = beginColor; color <= endColor; ++color) {
      int pay = c[i] == 0 ? p[i][color] : 0;
      for (int j = 0; j <= m; ++j) {
        for (int l = 0; l <= k; ++l) {
          if (dp[i - 1][j][l] == -1) continue;
          if (color == j) {
            dp[i][color][l] = dp[i][color][l] == -1
                                  ? (dp[i - 1][j][l] + pay)
                                  : min(dp[i][color][l], dp[i - 1][j][l] + pay);
          } else {
            dp[i][color][l + 1] =
                dp[i][color][l + 1] == -1
                    ? (dp[i - 1][j][l] + pay)
                    : min(dp[i][color][l + 1], dp[i - 1][j][l] + pay);
          }
        }
      }
    }
  }
  long long ans = -1;
  for (int i = 1; i <= m; ++i) {
    if (dp[n][i][k] == -1) continue;
    if (ans == -1) ans = dp[n][i][k];
    ans = min(ans, dp[n][i][k]);
  }
  cout << ans << endl;
  return 0;
}
