#include <bits/stdc++.h>
using namespace std;
long long int n, m, k, tree[100], clr[100][100];
long long int dp[105][105][105];
long long int solve(long long int idx, long long int div, long long int lclr) {
  if (idx == n && (div > k || div < k))
    return 1e18;
  else if (idx == n && div == k)
    return 0;
  if (idx != 0 && dp[idx][div][lclr] != -1) return dp[idx][div][lclr];
  long long int temp = 1e18;
  if (idx == 0 && tree[idx] != 0)
    temp = min(temp, solve(idx + 1, 1, tree[idx]));
  else if (idx == 0 && tree[idx] == 0) {
    for (long long int i = 0; i < m; i++)
      temp = min(temp, clr[idx][i] + solve(idx + 1, 1, i + 1));
  } else if (idx > 0) {
    if (tree[idx] != 0 && lclr == tree[idx])
      temp = min(temp, solve(idx + 1, div, lclr));
    else if (tree[idx] != 0 && lclr != tree[idx])
      temp = min(temp, solve(idx + 1, div + 1, tree[idx]));
    else if (tree[idx] == 0) {
      for (long long int i = 0; i < m; i++) {
        if (lclr == i + 1)
          temp = min(temp, clr[idx][i] + solve(idx + 1, div, lclr));
        else
          temp = min(temp, clr[idx][i] + solve(idx + 1, div + 1, i + 1));
      }
    }
  }
  return dp[idx][div][lclr] = temp;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(dp, -1, sizeof(dp));
  cin >> n >> m >> k;
  for (long long int i = 0; i < n; i++) cin >> tree[i];
  for (long long int i = 0; i < n; i++)
    for (long long int j = 0; j < m; j++) cin >> clr[i][j];
  long long int ans = solve(0, 0, -1);
  if (ans == 1e18)
    cout << -1;
  else
    cout << ans;
}
