#include <bits/stdc++.h>
using namespace std;
template <typename T>
T nextInt() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int maxn = (int)1e2 + 10;
const int inf = (int)1e9 + 5;
const int mod = (int)1e9 + 7;
const long long llinf = (long long)1e18 + 5;
const long double pi = acos(-1.0);
long long dp[maxn][maxn][maxn];
long long pref[maxn][maxn][maxn];
long long suff[maxn][maxn][maxn];
int n, k, m;
int c[maxn];
int a[maxn][maxn];
int main() {
  cin >> n >> m >> k;
  for (int i = (1); i < (n + 1); i++) cin >> c[i];
  for (int i = (1); i < (n + 1); i++)
    for (int j = (1); j < (m + 1); j++) cin >> a[i][j];
  for (int i = (0); i < (maxn); i++)
    for (int j = (0); j < (maxn); j++)
      for (int p = (0); p < (maxn); p++) dp[i][j][p] = llinf;
  dp[0][0][0] = 0;
  for (int j = (0); j < (k + 1); j++) {
    int i = 0;
    pref[i][j][0] = suff[i][j][m + 1] = llinf;
    for (int col = (0); col < (m + 1); col++)
      pref[i][j][col] =
          min(col == 0 ? llinf : pref[i][j][col - 1], dp[i][j][col]);
    for (int col = (m + 1) - 1; col >= (0); col--)
      suff[i][j][col] =
          min(col == m ? llinf : suff[i][j][col + 1], dp[i][j][col]);
  }
  for (int i = (1); i < (n + 1); i++) {
    int l = 1, r = m;
    if (c[i] != 0) l = r = c[i];
    for (int j = (1); j < (k + 1); j++) {
      for (int col = (l); col < (r + 1); col++) {
        dp[i][j][col] = dp[i - 1][j][col];
        dp[i][j][col] = min(dp[i][j][col], min(pref[i - 1][j - 1][col - 1],
                                               suff[i - 1][j - 1][col + 1]));
        if (dp[i][j][col] != llinf && c[i] == 0) dp[i][j][col] += a[i][col];
      }
    }
    for (int j = (0); j < (k + 1); j++) {
      pref[i][j][0] = suff[i][j][m + 1] = llinf;
      for (int col = (0); col < (m + 1); col++)
        pref[i][j][col] =
            min(col == 0 ? llinf : pref[i][j][col - 1], dp[i][j][col]);
      for (int col = (m + 1) - 1; col >= (0); col--)
        suff[i][j][col] =
            min(col == m ? llinf : suff[i][j][col + 1], dp[i][j][col]);
    }
  }
  long long res = llinf;
  for (int i = (1); i < (m + 1); i++) res = min(res, dp[n][k][i]);
  if (res == llinf) res = -1;
  cout << res << endl;
  return 0;
}
