#include <bits/stdc++.h>
using namespace std;
const int NUM = 110;
int N, M, K;
int c[NUM], p[NUM][NUM];
long long dp[NUM][NUM][NUM];
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("%d", &p[i][j]);
    }
  }
  memset(dp, 0x3f, sizeof(dp));
  if (c[1] == 0) {
    for (int j = 1; j <= M; ++j) dp[1][1][j] = p[1][j];
  } else
    dp[1][1][c[1]] = 0;
  for (int i = 2; i <= N; ++i) {
    for (int k = K; k >= 0; --k) {
      if (c[i] == 0) {
        long long mi1 = 0x3f3f3f3f3f3f3f3fll, c1 = 0,
                  mi2 = 0x3f3f3f3f3f3f3f3fll, c2 = 0;
        for (int j = 1; j <= M; ++j) {
          if (dp[i - 1][k][j] < mi1) {
            mi2 = mi1;
            c2 = c1;
            mi1 = dp[i - 1][k][j];
            c1 = j;
          } else if (dp[i - 1][k][j] < mi2) {
            mi2 = dp[i - 1][k][j];
            c2 = j;
          }
        }
        for (int j = 1; j <= M; ++j) {
          dp[i][k][j] = min(dp[i][k][j], dp[i - 1][k][j] + p[i][j]);
          if (j == c1) {
            dp[i][k + 1][j] = min(dp[i][k + 1][j], mi2 + p[i][j]);
          } else {
            dp[i][k + 1][j] = min(dp[i][k + 1][j], mi1 + p[i][j]);
          }
        }
      } else {
        for (int j = 1; j <= M; ++j) {
          if (j == c[i]) {
            dp[i][k][j] = min(dp[i][k][j], dp[i - 1][k][j]);
          } else {
            dp[i][k + 1][c[i]] = min(dp[i][k + 1][c[i]], dp[i - 1][k][j]);
          }
        }
      }
    }
  }
  long long ans = 0x3f3f3f3f3f3f3f3fll;
  if (c[N] == 0)
    for (int j = 1; j <= M; ++j) ans = min(ans, dp[N][K][j]);
  else
    ans = dp[N][K][c[N]];
  if (ans == 0x3f3f3f3f3f3f3f3fll) ans = -1;
  printf("%I64d\n", ans);
  return 0;
}
