#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using pill = pair<int, ll>;
using vvi = vector<vi>;
ll gcd(ll a, ll b) {
  ll t;
  while ((t = a % b) != 0) {
    a = b;
    b = t;
  }
  return b;
}
ll fast_exp(ll base, ll n, ll m) {
  if (n == 0) return 1;
  ll t = fast_exp(base, n / 2, m);
  if (n % 2 == 0)
    return (t * t) % m;
  else
    return (((t * t) % m) * base) % m;
}
bool is_set(int i, ll mask) { return (mask >> i) & 1; }
int count_bits(ll mask) {
  int ans = 0;
  for (int i = 0; i < 64; ++i)
    if (is_set(i, mask)) ++ans;
  return ans;
}
int first_bit(ll mask) {
  int i = 0;
  while (i < 64)
    if (is_set(i++, mask)) return i - 1;
  return -1;
}
ll dp[101][101][101];
int c[101];
ll p[101][101];
ll const inf = 1e12;
int main() {
  ios::sync_with_stdio(false);
  int n, m, K;
  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 >> p[i][j];
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= K; ++j)
      for (int k = 0; k <= m; ++k) dp[i][j][k] = inf;
  for (int i = 0; i <= K; ++i)
    for (int j = 0; j <= m; ++j) dp[0][i][j] = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= min(i, K); ++j)
      for (int k = 1; k <= m; ++k) {
        if (c[i] != 0 and c[i] != k) continue;
        for (int l = 1; l <= m; ++l) {
          if (l == k)
            dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][l]);
          else
            dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][l]);
        }
        if (c[i] == 0) dp[i][j][k] += p[i][k];
      }
  ll ans = inf;
  for (int i = 1; i <= m; ++i) ans = min(ans, dp[n][K][i]);
  if (ans >= inf)
    cout << "-1\n";
  else
    cout << ans << "\n";
  return 0;
}
