#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch <= '9' && ch >= '0'; x = x * 10 + ch - 48, ch = getchar())
    ;
  return x;
}
long long i, j, k, m, n, z, x, y, f[110][110][110], col[110], w[110][110], ans,
    o;
inline void Mn(long long& a, long long b) {
  if ((b < a || a == -1) && (b != -1)) a = b;
}
int main() {
  for (n = read(), m = read(), k = read(), i = 1; i <= n; ++i) col[i] = read();
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) w[i][j] = read();
  memset(f, -1, sizeof f), f[1][1][col[1]] = 0;
  if (!col[1])
    for (i = 1; i <= m; ++i) f[1][1][i] = w[1][i];
  for (i = 1; i < n; ++i) {
    for (j = 1; j <= i; ++j)
      for (o = 1; o <= m; ++o)
        if (f[i][j][o] != -1) {
          if (!col[i + 1]) {
            for (z = 1; z <= m; ++z)
              if (o != z)
                Mn(f[i + 1][j + 1][z], f[i][j][o] + w[i + 1][z]);
              else
                Mn(f[i + 1][j][z], f[i][j][o] + w[i + 1][z]);
          } else if (o != col[i + 1])
            Mn(f[i + 1][j + 1][col[i + 1]], f[i][j][o]);
          else
            Mn(f[i + 1][j][col[i + 1]], f[i][j][o]);
        }
  }
  for (ans = -1, i = 1; i <= m; ++i) Mn(ans, f[n][k][i]);
  printf("%I64d\n", ans);
}
