#include <bits/stdc++.h>
int n, m, k;
int c[100];
long long p[100][101];
long long dp[100][101][101];
int pre_color;
int original_printed_amount = 0;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    if (c[i] != 0 && (original_printed_amount == 0 || c[i] != pre_color)) {
      original_printed_amount++;
      pre_color = c[i];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%lld", &p[i][j]);
    }
  }
  if (original_printed_amount > k) {
    printf("-1");
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int x = 0; x <= n; x++) {
      for (int color = 1; color <= m; color++) {
        dp[i][x][color] = -1;
      }
    }
  }
  if (c[0] == 0) {
    for (int i = 1; i <= m; i++) {
      dp[0][1][i] = p[0][i];
    }
  } else {
    dp[0][1][c[0]] = 0;
  }
  for (int i = 1; i < n; i++) {
    for (int x = 1; x <= i + 1; x++) {
      if (c[i] != 0) {
        dp[i][x][c[i]] = dp[i - 1][x][c[i]];
        for (int color = 1; color <= m; color++) {
          if (color == c[i]) {
            continue;
          }
          dp[i][x][c[i]] =
              (dp[i][x][c[i]] == -1
                   ? dp[i - 1][x - 1][color]
                   : (dp[i - 1][x - 1][color] == -1
                          ? dp[i][x][c[i]]
                          : (dp[i][x][c[i]] < dp[i - 1][x - 1][color]
                                 ? dp[i][x][c[i]]
                                 : dp[i - 1][x - 1][color])));
        }
      } else {
        for (int c1 = 1; c1 <= m; c1++) {
          if (dp[i - 1][x][c1] != -1) {
            dp[i][x][c1] = dp[i - 1][x][c1] + p[i][c1];
          }
          for (int c2 = 1; c2 <= m; c2++) {
            if (c1 == c2) {
              continue;
            }
            if (dp[i - 1][x - 1][c2] != -1) {
              dp[i][x][c1] =
                  (dp[i][x][c1] == -1
                       ? dp[i - 1][x - 1][c2] + p[i][c1]
                       : (dp[i - 1][x - 1][c2] + p[i][c1] == -1
                              ? dp[i][x][c1]
                              : (dp[i][x][c1] < dp[i - 1][x - 1][c2] + p[i][c1]
                                     ? dp[i][x][c1]
                                     : dp[i - 1][x - 1][c2] + p[i][c1])));
            }
          }
        }
      }
    }
  }
  long long min_cost = -1;
  for (int color = 1; color <= m; color++) {
    min_cost =
        (min_cost == -1
             ? dp[n - 1][k][color]
             : (dp[n - 1][k][color] == -1
                    ? min_cost
                    : (min_cost < dp[n - 1][k][color] ? min_cost
                                                      : dp[n - 1][k][color])));
  }
  printf("%lld", min_cost);
}
