#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int c[105];
long long p[105][105], f[105][105][105];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%I64d", &p[i][j]);
  for (int i = 1; i <= n; i++)
    if (c[i]) p[i][c[i]] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int q = 0; q <= k; q++) f[i][j][q] = 1e16;
  if (c[1])
    f[1][c[1]][k - 1] = 0;
  else
    for (int i = 1; i <= m; i++) f[1][i][k - 1] = p[1][i];
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= m; j++)
      if (c[i] == 0 || j == c[i])
        for (int q = k - 1; q >= 0; q--) {
          if (q != 0) {
            for (int w = 1; w <= m; w++)
              if (j != w)
                f[i + 1][w][q - 1] =
                    min(f[i + 1][w][q - 1], f[i][j][q] + p[i + 1][w]);
          }
          f[i + 1][j][q] = min(f[i + 1][j][q], f[i][j][q] + p[i + 1][j]);
        }
  }
  long long ans = 1e16;
  if (c[n]) {
    ans = min(ans, f[n][c[n]][0]);
  } else
    for (int i = 1; i <= m; i++) ans = min(f[n][i][0], ans);
  if (ans == 1e16)
    printf("-1");
  else
    printf("%I64d", ans);
  return 0;
}
