#include <bits/stdc++.h>
using namespace std;
const int MAXN = 112;
const long long INF = (long long)1e14;
const long long MOD = 1000000007;
int m, b[MAXN], t;
int n, k;
int c[MAXN], p[MAXN][MAXN];
long long dp[MAXN][MAXN][MAXN];
long long solve(int tam, int quero, int cor) {
  ;
  if (n == tam) {
    if (quero == 0)
      return 0;
    else
      return INF;
  }
  if (dp[tam][quero][cor] != -1) return dp[tam][quero][cor];
  if (c[tam] != 0) {
    if (c[tam] == cor) {
      return dp[tam][quero][cor] = solve(tam + 1, quero, cor);
    } else {
      return dp[tam][quero][cor] = solve(tam + 1, quero - 1, c[tam]);
    }
  }
  if (c[tam] == 0) {
    long long ret = INF;
    if (true) {
      for (int i = 1; i <= m; i++) {
        if (i == cor) {
          ;
          ret = min(ret, solve(tam + 1, quero, cor) + p[tam][cor]);
        } else {
          ;
          ret = min(ret, solve(tam + 1, quero - 1, i) + p[tam][i]);
        }
      }
      return dp[tam][quero][cor] = ret;
    }
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  long long resp = solve(0, k, 0);
  if (resp == INF)
    puts("-1");
  else
    printf("%I64d\n", resp);
  return 0;
}
