#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
long long dp[105][105][105];
long long c[105], val[105][105], ans = INF;
int main() {
  int i, j, K, n, m, k;
  cin >> n >> m >> K;
  for (i = 1; i <= n; i++) cin >> c[i];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> val[i][j];
    }
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0][0] = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j <= m; j++) {
      for (k = 0; k <= i; k++) {
        if (dp[i][j][k] != INF) {
          if (c[i + 1]) {
            dp[i + 1][c[i + 1]][k + (c[i + 1] != j)] =
                min(dp[i + 1][c[i + 1]][k + (c[i + 1] != j)], dp[i][j][k]);
          } else {
            for (int p = 1; p <= m; p++) {
              dp[i + 1][p][k + (p != j)] =
                  min(dp[i][j][k] + val[i + 1][p], dp[i + 1][p][k + (p != j)]);
            }
          }
        }
      }
    }
  }
  for (i = 1; i <= m; i++) {
    ans = min(dp[n][i][K], ans);
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
