#include <bits/stdc++.h>
using namespace std;
long long k, n, m;
long long c[105];
long long a[105][105];
long long dp[105][105][105];
long long c1, c2, c3, c4, goal, t1, t2, t3, t4;
void init() {
  memset(dp, 0x3f, sizeof(dp));
  memset(a, 0, sizeof(a));
  memset(c, 0, sizeof(c));
  c1 = c2 = c3 = c4 = 0;
  dp[0][0][0] = 0;
  goal = 0x3f3f3f3f3f3f3f3fLL;
}
int main() {
  init();
  scanf("%I64d%I64d%I64d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &c[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%I64d", &a[i][j]);
      if (c[i] != 0) a[i][j] = 0;
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      for (long long l1 = 1; l1 <= m; l1++) {
        if (c[i] != 0 && c[i] != l1) continue;
        for (long long l2 = 0; l2 <= m; l2++) {
          if (l1 != l2) {
            dp[i][l1][j + 1] =
                min(dp[i][l1][j + 1], dp[i - 1][l2][j] + a[i][l1]);
          } else {
            dp[i][l1][j] = min(dp[i][l1][j], dp[i - 1][l2][j] + a[i][l1]);
          }
        }
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    goal = min(goal, dp[n][i][k]);
  }
  if (goal == 0x3f3f3f3f3f3f3f3fLL) {
    printf("-1\n");
    return 0;
  }
  printf("%I64d\n", goal);
  return 0;
}
