#include <bits/stdc++.h>
using namespace std;
int arr[101];
long long n, m, k;
int paint[101][101] = {};
long long dp[102][102][102] = {};
void init() {
  for (int i = 0; i < 102; i++) {
    for (int j = 0; j < 102; j++) {
      for (int k = 0; k < 102; k++) {
        dp[i][j][k] = -1;
      }
    }
  }
}
long long calc(int i, int last, int k) {
  if (i == n) {
    if (k == 0)
      return 0;
    else
      return 10000000000000;
  }
  if (dp[i][last][k] != -1) return dp[i][last][k];
  if (arr[i] != -1) {
    if (arr[i] == last) {
      dp[i][last][k] = calc(i + 1, last, k);
    } else {
      dp[i][last][k] = calc(i + 1, arr[i], k - 1);
    }
  } else {
    long long ans = 10000000000000;
    for (int j = 0; j < m; j++) {
      if (j + 1 != last) {
        long long val = paint[i][j] + calc(i + 1, j + 1, k - 1);
        ans = min(ans, val);
      }
    }
    if (last != 0) {
      long long val = paint[i][last - 1] + calc(i + 1, last, k);
      ans = min(ans, val);
    }
    dp[i][last][k] = ans;
  }
  return dp[i][last][k];
}
void solve() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> arr[i];
  ;
  for (int i = 0; i < n; i++)
    if (arr[i] == 0) arr[i] = -1;
  init();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> paint[i][j];
    }
  }
  long long ans = calc(0, 0, k);
  if (ans >= 10000000000000) ans = -1;
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
