#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
const long long Max = 999999999999;
long long dp[maxn][maxn][maxn];
int p[maxn][maxn];
int a[maxn];
int main() {
  int n, m, t;
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &p[i][j]);
    }
  }
  int c = n;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= c; j++)
      for (int k = 1; k <= m; k++) dp[i][j][k] = Max;
  if (a[1] == 0)
    for (int k = 1; k <= m; k++) dp[1][1][k] = p[1][k];
  else
    dp[1][1][a[1]] = 0;
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= c; j++) {
      if (a[i]) {
        dp[i][j][a[i]] = dp[i - 1][j][a[i]];
        for (int k = 1; k <= m; k++)
          if (k != a[i])
            dp[i][j][a[i]] = min(dp[i][j][a[i]], dp[i - 1][j - 1][k]);
      } else {
        for (int k = 1; k <= m; k++) {
          dp[i][j][k] = dp[i - 1][j][k];
          for (int r = 1; r <= m; r++)
            if (r != k) dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][r]);
          dp[i][j][k] += p[i][k];
        }
      }
    }
  }
  long long ans = Max;
  for (int i = 1; i <= m; i++) ans = min(ans, dp[n][t][i]);
  if (ans == Max) ans = -1;
  printf("%lld\n", ans);
}
