#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 5;
const long long INF = 1e15;
long long dp[MAXN][MAXN][MAXN], p[MAXN][MAXN], c[MAXN];
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];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= k; j++)
      for (int col = 0; col <= m; col++) dp[i][j][col] = INF;
  for (int col = 1; col <= m; col++) {
    if (c[1] != 0)
      dp[1][1][col] = (col == c[1]) ? 0 : INF;
    else
      dp[1][1][col] = p[1][col];
  }
  for (int i = 2; i <= n; i++)
    for (int j = 1; j <= k; j++) {
      for (int col = 1; col <= m; col++) {
        dp[i][j][col] = INF;
        if (c[i] != 0 && col != c[i]) continue;
        for (int pre = 1; pre <= m; pre++) {
          long long cost = (c[i] == 0) ? p[i][col] : 0;
          int dec = (pre == col) ? 0 : 1;
          dp[i][j][col] = min(dp[i][j][col], dp[i - 1][j - dec][pre] + cost);
        }
      }
    }
  long long ans = INF;
  for (int i = 1; i <= m; i++) {
    ans = min(ans, dp[n][k][i]);
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
