#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int n, k, m;
int arr[105];
long long cst[105][105];
long long dp[105][105][105];
long long LNF = 1e16;
long long solve(int pos, int rong, int beauty) {
  if (pos > n) {
    if (beauty == k)
      return 0;
    else
      return LNF;
  }
  if (dp[pos][rong][beauty] != -1) return dp[pos][rong][beauty];
  long long ret = LNF;
  if (arr[pos] == 0) {
    for (int i = 1; i <= m; i++) {
      if (i == rong)
        ret = min(ret, cst[pos][i] + solve(pos + 1, i, beauty));
      else
        ret = min(ret, cst[pos][i] + solve(pos + 1, i, beauty + 1));
    }
  } else {
    if (arr[pos] == rong)
      ret = min(ret, solve(pos + 1, arr[pos], beauty));
    else
      ret = min(ret, solve(pos + 1, arr[pos], beauty + 1));
  }
  dp[pos][rong][beauty] = ret;
  return dp[pos][rong][beauty];
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  bool all = true;
  for (int i = 1; i <= n; i++) {
    scanf("%d", arr + i);
    if (arr[i] == 0) all = false;
  }
  for (int i = 1; i <= n; i++) {
    long long x;
    for (int j = 1; j <= m; j++) {
      scanf("%I64d", &x);
      cst[i][j] = x;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] != arr[i + 1]) {
      cnt++;
      if (i + 1 == n) {
        cnt++;
        i++;
      }
    }
  }
  if (all) {
    if (cnt == k)
      printf("0");
    else
      printf("-1");
    return 0;
  }
  memset(dp, -1, sizeof dp);
  long long ret = solve(1, 0, 0);
  if (ret >= LNF)
    printf("-1");
  else
    printf("%I64d", ret);
}
