#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0, 0, 0, 0, 0};
int dy[] = {0, 0, 1, -1, 0, 0, 0, 0};
const long long inf = 1000000000;
const double eps = 0.000000009;
long long n, m, k;
vector<long long> a;
vector<vector<long long> > p;
long long dp[105][105][105];
long long recur(int c, int prev, int kk) {
  if (kk > k) return 1e14;
  if (c == n) {
    if (kk == k) return 0;
    return 1e14;
  }
  if (a[c]) {
    if (a[c] == prev)
      return recur(c + 1, a[c], kk);
    else
      return recur(c + 1, a[c], kk + 1);
  }
  if (dp[c][prev][kk] != -1) return dp[c][prev][kk];
  long long ans = 1e14;
  for (int i = 1; i <= m; i++) {
    if (prev == i) {
      ans = min(ans, recur(c + 1, i, kk) + p[c][i - 1]);
    } else {
      ans = min(ans, recur(c + 1, i, kk + 1) + p[c][i - 1]);
    }
  }
  return dp[c][prev][kk] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> k;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < n; i++) {
    vector<long long> x;
    for (int j = 0; j < m; j++) {
      long long xx;
      cin >> xx;
      x.push_back(xx);
    }
    p.push_back(x);
  }
  long long ans = recur(0, 0, 0);
  if (ans == 1e14)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
