#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 5;
const long long M = 1e9 + 7;
const long long inf = 1e17 + 5;
int n, m, k;
int col[N];
long long mat[N][N];
long long dp[N][N][N];
long long rec(int pos, int fin, int prec) {
  if (pos == n) {
    if (fin == k) {
      if (col[n] != 0) {
        if (prec == col[n]) {
          return 0;
        } else
          return inf;
      } else {
        return mat[n][prec];
      }
    } else if (fin == k - 1) {
      if (col[n] != 0) {
        if (prec == col[n]) {
          return inf;
        } else
          return 0;
      } else {
        long long res = inf;
        for (int i = 1; i <= m; i++) {
          if (i != prec) {
            res = min(res, mat[n][i]);
          }
        }
        return res;
      }
    } else
      return inf;
  }
  if (fin > k) return inf;
  long long &res = dp[pos][fin][prec];
  if (res != -1) return res;
  res = inf;
  if (col[pos] != 0) {
    if (col[pos] == prec)
      res = rec(pos + 1, fin, prec);
    else {
      res = rec(pos + 1, fin + 1, col[pos]);
    }
  } else {
    for (int i = 1; i <= m; i++) {
      if (i == prec)
        res = min(res, mat[pos][i] + rec(pos + 1, fin, prec));
      else
        res = min(res, mat[pos][i] + rec(pos + 1, fin + 1, i));
    }
  }
  return res;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &k);
  for (int i = 1; i <= n; i++) scanf("%d", &col[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) scanf("%lld", &mat[i][j]);
  }
  memset(dp, -1, sizeof(dp));
  long long ans = rec(1, 0, 0);
  if (ans >= inf) ans = -1;
  printf("%lld\n", ans);
  ;
}
