#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
int c[110];
long long p[110][110];
long long f[110][110][110];
int main() {
  int n, m, cnt;
  scanf("%d%d%d", &n, &m, &cnt);
  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]);
  memset(f, 0X3F, sizeof(f));
  for (int i = 0; i <= m; ++i) f[0][0][i] = 0;
  if (c[1])
    f[1][1][c[1]] = 0;
  else
    for (int i = 1; i <= m; ++i) f[1][1][i] = p[1][i];
  for (int i = 1; i <= n; ++i) {
    if (c[i]) {
      for (int k = 1; k <= cnt; ++k)
        if (c[i - 1]) {
          if (c[i] == c[i - 1]) {
            if (f[i - 1][k][c[i - 1]] < f[i][k][c[i]])
              f[i][k][c[i]] = f[i - 1][k][c[i - 1]];
          } else {
            if (f[i - 1][k - 1][c[i - 1]] < f[i][k][c[i]])
              f[i][k][c[i]] = f[i - 1][k - 1][c[i - 1]];
          }
        } else {
          for (int lco = 1; lco <= m; ++lco)
            if (lco != c[i]) {
              if (f[i - 1][k - 1][lco] < f[i][k][c[i]])
                f[i][k][c[i]] = f[i - 1][k - 1][lco];
            } else {
              if (f[i - 1][k][lco] < f[i][k][c[i]])
                f[i][k][c[i]] = f[i - 1][k][lco];
            }
        }
    } else {
      for (int k = 1; k <= cnt; ++k)
        if (c[i - 1]) {
          for (int co = 1; co <= m; ++co)
            if (co == c[i - 1]) {
              if (f[i - 1][k][c[i - 1]] + p[i][co] < f[i][k][co])
                f[i][k][co] = f[i - 1][k][c[i - 1]] + p[i][co];
            } else {
              if (f[i - 1][k - 1][c[i - 1]] + p[i][co] < f[i][k][co])
                f[i][k][co] = f[i - 1][k - 1][c[i - 1]] + p[i][co];
            }
        } else {
          for (int lco = 1; lco <= m; ++lco)
            for (int co = 1; co <= m; ++co)
              if (co != lco) {
                if (f[i - 1][k - 1][lco] + p[i][co] < f[i][k][co])
                  f[i][k][co] = f[i - 1][k - 1][lco] + p[i][co];
              } else {
                if (f[i - 1][k][lco] + p[i][co] < f[i][k][co])
                  f[i][k][co] = f[i - 1][k][lco] + p[i][co];
              }
        }
    }
  }
  long long ans = 0X3F3F3F3F3F3F3F3F;
  for (int i = 1; i <= m; ++i)
    if (f[n][cnt][i] < ans) ans = f[n][cnt][i];
  if (ans == 0X3F3F3F3F3F3F3F3F)
    puts("-1");
  else
    printf("%I64d\n", ans);
  return 0;
}
