#include <bits/stdc++.h>
using namespace std;
const int inf = (1 << 30) - 1;
const int maxn = 110;
int n, m, K;
long long f[maxn][maxn][maxn];
int col[maxn];
long long p[maxn][maxn];
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= n; i++) scanf("%d", &col[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%I64d", &p[i][j]);
  memset(f, 0x3f, sizeof(f));
  long long INF = f[0][0][0];
  f[0][0][0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int k = 0; k <= K; k++) {
        if (col[i])
          f[i][col[i]][k + (j != col[i])] =
              min(f[i][col[i]][k + (j != col[i])], f[i - 1][j][k]);
        else
          for (int w = 1; w <= m; w++)
            f[i][w][k + (j != w)] =
                min(f[i][w][k + (j != w)], f[i - 1][j][k] + p[i][w]);
      }
  long long ans = INF;
  for (int i = 0; i <= m; i++) ans = min(ans, f[n][i][K]);
  if (ans == INF) ans = -1;
  printf("%I64d\n", ans);
  return 0;
}
