#include <bits/stdc++.h>
using namespace std;
const long long inf = 999999999999999;
long long dp[110][110][110];
long long a[110][110];
int main() {
  int n, m, k;
  int color[110];
  while (scanf("%d%d%d", &n, &m, &k) != EOF) {
    for (int i = 0; i <= n; i++)
      for (int j = 0; j <= m; j++)
        for (int t = 0; t <= k; t++) dp[i][t][j] = inf;
    for (int i = 1; i <= n; i++) scanf("%d", &color[i]);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf("%I64d", &a[i][j]);
    if (color[1] == 0) {
      for (int j = 1; j <= m; j++) dp[1][1][j] = a[1][j];
    } else
      dp[1][1][color[1]] = 0;
    for (int i = 2; i <= n; i++) {
      if (color[i] != 0) {
        for (int ip = 1; ip <= m; ip++) {
          if (color[i] == ip) {
            for (int t = 1; t <= k; t++)
              dp[i][t][color[i]] = min(dp[i][t][color[i]], dp[i - 1][t][ip]);
          } else {
            for (int t = 1; t <= k; t++)
              dp[i][t][color[i]] =
                  min(dp[i][t][color[i]], dp[i - 1][t - 1][ip]);
          }
        }
      } else {
        for (int ip = 1; ip <= m; ip++) {
          for (int j = 1; j <= m; j++) {
            if (j == ip) {
              for (int t = 1; t <= k; t++)
                dp[i][t][j] = min(dp[i][t][j], dp[i - 1][t][ip] + a[i][j]);
            } else {
              for (int t = 2; t <= k; t++)
                dp[i][t][j] = min(dp[i][t][j], dp[i - 1][t - 1][ip] + a[i][j]);
            }
          }
        }
      }
    }
    long long ans = inf;
    for (int j = 1; j <= m; j++) ans = min(ans, dp[n][k][j]);
    if (ans >= inf)
      printf("-1\n");
    else
      printf("%I64d\n", ans);
  }
  return 0;
}
