#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
inline void read(long long &x) {
  x = 0;
  register char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 3) + (x << 1) + (c - '0');
}
inline void write(long long x) {
  register char buffor[35];
  register long long i = 0;
  do {
    buffor[i++] = (x % 10) + '0';
    x /= 10;
  } while (x);
  i--;
  while (i >= 0) putchar(buffor[i--]);
  putchar('\n');
}
inline long long in() {
  long long x;
  read(x);
  return x;
}
void solve();
long long dbg = 1, inf = 1e16;
using namespace std;
int main() {
  long long t = 1;
  for (long long i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
long long n, m, k, a[105], arr[105][105], dp[105][105][105];
long long func(long long cu, long long co, long long v) {
  if (cu < 0)
    if (v == 1)
      return 0;
    else
      return inf;
  else if (cu == 0 && v > 1)
    return inf;
  if (a[cu] && a[cu] != co) return inf;
  if (dp[cu][co][v] != -1) return dp[cu][co][v];
  long long ans = inf;
  ans = min(ans, func(cu - 1, co, v) + (a[cu] > 0 ? 0 : arr[cu][co]));
  for (long long i = 1; i <= m && v > 1; i++) {
    if (i == co) continue;
    ans = min(ans, func(cu - 1, i, v - 1) + (a[cu] > 0 ? 0 : arr[cu][co]));
  }
  return dp[cu][co][v] = ans;
}
void solve() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> m >> k;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++)
    for (long long j = 1; j <= m; j++) cin >> arr[i][j];
  long long ans = inf;
  for (long long i = 1; i <= m; i++) ans = min(ans, func(n - 1, i, k));
  if (ans == inf) ans = -1;
  cout << ans << endl;
}
