#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
long long d[107][107][107];
int n, m, k;
vector<int> c;
long long p[107][107];
long long f(int ind, int prev, int left) {
  if (left < 0) return INF;
  if (d[ind][prev][left] != -1) return d[ind][prev][left];
  if (ind == n) return d[ind][prev][left] = (left ? INF : 0);
  if (c[ind] != -1)
    return d[ind][prev][left] =
               f(ind + 1, c[ind], left - (!ind || prev != c[ind]));
  long long ans = INF;
  for (int j = 0; j < m; ++j)
    ans = min(ans, p[ind][j] + f(ind + 1, j, left - (!ind || prev != j)));
  return d[ind][prev][left] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(d, -1, sizeof d);
  int gr = 0, last = 107;
  scanf("%d%d%d", &n, &m, &k);
  c.resize(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    --c[i];
    if (c[i] != -1) {
      if (!i || c[i] != last) ++gr;
      last = c[i];
    }
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%I64d", &p[i][j]);
  if (k < gr) {
    printf("-1");
    return 0;
  }
  long long ans = f(0, n, k);
  printf("%I64d", ans == INF ? -1 : ans);
  return 0;
}
