#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e12;
const int MaxN = 128;
long long dp[MaxN][MaxN][MaxN];
long long c[MaxN], p[MaxN][MaxN];
int main() {
  ios::sync_with_stdio(false);
  long long n, m, kkk;
  cin >> n >> m >> kkk;
  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 < MaxN; i++)
    for (int j = 0; j < MaxN; j++)
      for (int k = 0; k < MaxN; k++) dp[i][j][k] = -1;
  if (c[1] == 0LL) {
    for (int i = 1; i <= m; i++) dp[1][i][1] = p[1][i];
  } else {
    dp[1][c[1]][1] = 0;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = 1; k <= kkk; k++) {
        if (c[i] != 0LL && j != c[i]) {
          dp[i][j][k] = -1LL;
          continue;
        } else {
          dp[i][j][k] = INF;
          for (int l = 1; l <= m; l++) {
            if (l == j) {
              if (dp[i - 1][l][k] == -1LL)
                continue;
              else
                dp[i][j][k] =
                    min(dp[i][j][k],
                        dp[i - 1][l][k] + p[i][j] * (j == c[i] ? 0 : 1));
            } else {
              if (dp[i - 1][l][k - 1] == -1LL)
                continue;
              else
                dp[i][j][k] =
                    min(dp[i][j][k],
                        dp[i - 1][l][k - 1] + p[i][j] * (j == c[i] ? 0 : 1));
            }
          }
        }
      }
    }
  }
  long long ans = INF;
  for (int i = 1; i <= m; i++)
    if (dp[n][i][kkk] != -1) ans = min(ans, dp[n][i][kkk]);
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}
