#include <bits/stdc++.h>
using namespace std;
long long n, m, k, c[111], p[111][111], dp[111][111][111];
long long solve(int idx, int prv, int cnt) {
  if (idx >= n) return (cnt == k) ? 0 : 2e15;
  long long& ret = dp[idx][prv][cnt];
  if (ret != -1) return ret;
  if (c[idx] != 0) return ret = solve(idx + 1, c[idx], cnt + (c[idx] != prv));
  ret = 2e15;
  for (int i = 1; i <= m; ++i) {
    ret = min(ret, solve(idx + 1, i, cnt + (i != prv)) + p[idx][i]);
  }
  return ret;
}
int main() {
  int i, j;
  cin >> n >> m >> k;
  for (i = 0; i < n; ++i) cin >> c[i];
  for (i = 0; i < n; ++i)
    for (j = 1; j <= m; ++j) cin >> p[i][j];
  memset(dp, -1, sizeof(dp));
  long long ans = solve(0, m + 3, 0);
  cout << (ans == 2e15 ? -1 : ans) << endl;
  return 0;
}
