#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (long long i = 0; i < v.size(); ++i) os << v[i] << " ";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (auto it : v) os << it << " ";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << v.first << " " << v.second;
  return os;
}
const long long mod = 1e9 + 7;
const long long inf = 2e18;
const long long ninf = -2e18;
const long long N = 102;
long long n, m;
vector<long long> arr(N);
vector<vector<long long>> costs(N);
long long dp[N][N][N];
long long takemod(long long a) { return ((a % mod) + mod) % mod; }
long long pow(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long modinv(long long a) { return takemod(pow(takemod(a), mod - 2, mod)); }
long long solve(long long i, long long j, long long k) {
  if (dp[i][j][k] != -1) return dp[i][j][k];
  if (i == 0) {
    if (j != 0)
      return inf;
    else
      return 0;
  }
  if (j == 0) {
    if (arr[i] == k) {
      return dp[i][j][k] = solve(i - 1, 0, k);
    } else if (arr[i] == 0)
      return dp[i][j][k] = solve(i - 1, 0, k) + costs[i][k - 1];
    else
      return dp[i][j][k] = inf;
  }
  long long col = arr[i];
  long long ans = inf;
  if (col == 0) {
    for (long long f = 1; f <= m; f++) {
      if (f == k)
        ans = min(ans, solve(i - 1, j, f) + costs[i][f - 1]);
      else
        ans = min(ans, solve(i - 1, j - 1, f) + costs[i][f - 1]);
    }
  } else {
    if (col == k)
      ans = min(ans, solve(i - 1, j, k));
    else
      ans = min(ans, solve(i - 1, j - 1, col));
  }
  if (ans > inf) ans = inf;
  return dp[i][j][k] = ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  time_t t1, t2;
  t1 = clock();
  long long k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      long long x;
      cin >> x;
      costs[i].push_back(x);
    }
  }
  memset(dp, -1, sizeof(dp));
  long long ans = inf;
  if (arr[n] == 0) {
    ans = solve(n, k, m + 1);
  } else {
    ans = solve(n, k - 1, arr[n]);
  }
  if (ans >= inf)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
  t2 = clock();
  cerr << '\n' << t2 - t1 << '\n';
  return 0;
}
