#include <bits/stdc++.h>
using namespace std;
const int N = 101;
const long long inf = 1e11 + 5;
int n, m, k, c[N];
long long p[N][N], dp[N][N][N], ans;
long long solve(int tree, int rem, int lst) {
  if (tree == n) return rem ? inf : 0;
  long long &ret = dp[tree][rem][lst];
  if (ret != -1) return ret;
  ret = inf;
  if (c[tree]) {
    if (rem >= (c[tree] != lst))
      ret = solve(tree + 1, rem - (c[tree] != lst), c[tree]);
  } else {
    for (int i = 1; i <= m; ++i) {
      if (rem >= (i != lst))
        ret = min(ret, p[tree][i] + solve(tree + 1, rem - (i != lst), i));
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> p[i][j];
    }
  }
  memset(dp, -1, sizeof(dp));
  ans = solve(0, k, 0);
  cout << (ans == inf ? -1 : ans) << endl;
  return 0;
}
