#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e2 + 5;
int n, m, k;
long long int ar[N], cost[N][N], dp[N][N][N];
long long int recur(long long int idx, long long int par, long long int pcol) {
  if (idx > n) {
    if (par == k) return 0;
    return 100000000000LL + 1;
  }
  if (dp[idx][par][pcol] != -1) return dp[idx][par][pcol];
  if (ar[idx] == 0) {
    dp[idx][par][pcol] = 100000000000LL;
    for (int i = 1; i <= m; i++) {
      dp[idx][par][pcol] =
          min(dp[idx][par][pcol],
              recur(idx + 1, par + (i == pcol ? 0 : 1), i) + cost[idx][i]);
    }
    return dp[idx][par][pcol];
  } else {
    if (pcol == ar[idx])
      return dp[idx][par][pcol] = recur(idx + 1, par, ar[idx]);
    else
      return dp[idx][par][pcol] = recur(idx + 1, par + 1, ar[idx]);
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> ar[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> cost[i][j];
    }
  }
  for (int i = 0; i <= N - 1; i++) {
    for (int j = 0; j <= N - 1; j++) {
      for (int k = 0; k <= N - 1; k++) dp[i][j][k] = -1;
    }
  }
  long long int ans = recur(1, 0, ar[0]);
  if (ans >= 100000000000LL)
    cout << -1;
  else
    cout << ans;
  return 0;
}
