#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
const int MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
long long power(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) res *= a;
    a *= a;
    n /= 2;
  }
  return res;
}
long long abst(long long a) { return ((a < 0) ? (-1 * a) : (a)); }
long long n, m, k;
long long c[105];
long long arr[105][105], dp[105][105][105];
long long fun(long long i, long long pre, long long bt) {
  if (i == (n + 1)) {
    if (bt == k)
      return 0;
    else
      return 1e14;
  }
  if (dp[i][pre][bt] != -1) return dp[i][pre][bt];
  long long ans = 1e14;
  if (c[i] != 0) {
    if (c[i] != pre)
      return fun(i + 1, c[i], bt + 1);
    else
      return fun(i + 1, c[i], bt);
  } else {
    for (int j = 1; j <= m; j++) {
      if (j == pre)
        ans = min(ans, fun(i + 1, j, bt) + arr[i][j]);
      else
        ans = min(ans, fun(i + 1, j, bt + 1) + arr[i][j]);
    }
  }
  return dp[i][pre][bt] = ans;
}
int main() {
  memset(dp, -1, sizeof(dp));
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> arr[i][j];
    }
  }
  long long res = 1e12;
  res = min(res, fun(1, 0, 0));
  if (res == 1e12)
    cout << -1 << "\n";
  else
    cout << res << "\n";
  return 0;
}
