#include <bits/stdc++.h>
using namespace std;
int n, k, m;
int a[111];
int c[111][111];
long long dp[111][111][111];
long long f(int idx, int cnt, int last) {
  if (idx > n) return cnt == k ? 0 : 1e13;
  if (dp[idx][cnt][last] != -1) return dp[idx][cnt][last];
  long long ans = 1e13;
  if (a[idx])
    ans = min(ans, f(idx + 1, cnt + (a[idx] == last ? 0 : 1), a[idx]));
  else {
    for (int i = 1; i <= m; i++)
      ans = min(ans, f(idx + 1, cnt + (last == i ? 0 : 1), i) + c[idx][i]);
  }
  return dp[idx][cnt][last] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, -1, sizeof dp);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[0] = 111;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> c[i][j];
  long long ans = f(1, 0, 111);
  if (ans > 1e12)
    cout << -1;
  else
    cout << ans;
  return 0;
}
