#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
long long dp[MAXN][MAXN][MAXN];
int n, k, m;
int col[MAXN];
long long p[MAXN][MAXN];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  col[0] = -1;
  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("%lld", &p[i][j]);
  }
  for (int i = 1; i <= m; ++i)
    for (int j = 1; j <= k; ++j) dp[0][i][j] = -1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      for (int l = 0; l <= k; ++l) dp[i][j][l] = -1;
  for (int i = 1; i <= n; ++i) {
    if (col[i] != 0) {
      if (i == 1) {
        dp[i][col[i]][1] = 0;
        continue;
      }
      for (int j = 1; j <= k; ++j) {
        long long x = -1;
        for (int c = 1; c <= m; ++c) {
          if (col[i] == c) {
            if (dp[i - 1][c][j] != -1)
              x = (x == -1) ? dp[i - 1][c][j] : min(x, dp[i - 1][c][j]);
          } else {
            if (dp[i - 1][c][j - 1] != -1)
              x = (x == -1) ? dp[i - 1][c][j - 1] : min(x, dp[i - 1][c][j - 1]);
          }
        }
        dp[i][col[i]][j] = x;
      }
      continue;
    }
    if (i == 1) {
      for (int c = 1; c <= m; ++c) dp[i][c][1] = p[i][c];
      continue;
    }
    for (int c = 1; c <= m; ++c) {
      for (int j = 1; j <= k; ++j) {
        long long x = -1;
        for (int c1 = 1; c1 <= m; ++c1) {
          if (c == c1) {
            if (dp[i - 1][c1][j] != -1)
              x = (x == -1) ? dp[i - 1][c1][j] : min(x, dp[i - 1][c1][j]);
          } else {
            if (dp[i - 1][c1][j - 1] != -1)
              x = (x == -1) ? dp[i - 1][c1][j - 1]
                            : min(x, dp[i - 1][c1][j - 1]);
          }
        }
        if (x == -1)
          dp[i][c][j] = -1;
        else
          dp[i][c][j] = x + p[i][c];
      }
    }
  }
  long long ans = -1;
  for (int i = 1; i <= m; ++i) {
    if (dp[n][i][k] == -1) continue;
    if (ans == -1)
      ans = dp[n][i][k];
    else
      ans = min(ans, dp[n][i][k]);
  }
  printf("%lld\n", ans);
  return 0;
}
