#include <bits/stdc++.h>
using namespace std;
int n, m, k, c[102];
long long dp[102][102][102], p[102][102], painted;
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("%I64d", &p[i][j]);
      if (c[i] == j) painted += p[i][j];
    }
  for (int i = 1; i <= n; i++) {
    if (c[i]) {
      if (i == 1) {
        dp[i][c[i]][1] = p[i][c[i]];
      } else {
        if (c[i - 1]) {
          for (int kk = 1; kk <= min(k, i); kk++)
            if (dp[i - 1][c[i - 1]][kk] &&
                (!dp[i][c[i]][kk + (c[i] != c[i - 1])] ||
                 dp[i - 1][c[i - 1]][kk] + p[i][c[i]] <
                     dp[i][c[i]][kk + (c[i] != c[i - 1])]))
              dp[i][c[i]][kk + (c[i] != c[i - 1])] =
                  dp[i - 1][c[i - 1]][kk] + p[i][c[i]];
        } else {
          for (int color = 1; color <= m; color++)
            for (int kk = 1; kk <= min(k, i); kk++)
              if (dp[i - 1][color][kk] &&
                  (!dp[i][c[i]][kk + (c[i] != color)] ||
                   dp[i - 1][color][kk] + p[i][c[i]] <
                       dp[i][c[i]][kk + (c[i] != color)]))
                dp[i][c[i]][kk + (c[i] != color)] =
                    dp[i - 1][color][kk] + p[i][c[i]];
        }
      }
    } else {
      if (i == 1) {
        for (int color = 1; color <= m; color++) dp[i][color][1] = p[i][color];
      } else {
        if (c[i - 1]) {
          for (int clr = 1; clr <= m; clr++)
            for (int kk = 1; kk <= min(k, i); kk++)
              if (dp[i - 1][c[i - 1]][kk] &&
                  (!dp[i][clr][kk + (clr != c[i - 1])] ||
                   dp[i - 1][c[i - 1]][kk] + p[i][clr] <
                       dp[i][clr][kk + (clr != c[i - 1])]))
                dp[i][clr][kk + (clr != c[i - 1])] =
                    dp[i - 1][c[i - 1]][kk] + p[i][clr];
        } else {
          for (int clr = 1; clr <= m; clr++)
            for (int color = 1; color <= m; color++)
              for (int kk = 1; kk <= min(k, i); kk++)
                if (dp[i - 1][color][kk] &&
                    (!dp[i][clr][kk + (clr != color)] ||
                     dp[i - 1][color][kk] + p[i][clr] <
                         dp[i][clr][kk + (clr != color)]))
                  dp[i][clr][kk + (clr != color)] =
                      dp[i - 1][color][kk] + p[i][clr];
        }
      }
    }
  }
  long long ans = 2e18;
  for (int clr = 1; clr <= m; clr++)
    if (dp[n][clr][k]) ans = min(ans, dp[n][clr][k] - painted);
  if (ans == 2e18)
    printf("-1\n");
  else
    printf("%I64d\n", ans);
  return 0;
}
