#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
const long long INF = 100000000000000007ll;
long long dp[maxn][maxn][maxn];
int n, m, k, p[maxn][maxn], a[maxn];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  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]);
  if (a[1] == 0)
    for (int j = 1; j <= m; j++)
      for (int z = 1; z <= k; z++) dp[1][j][z] = z == 1 ? p[1][j] : INF;
  else {
    for (int j = 1; j <= m; j++)
      for (int z = 1; z <= k; z++) dp[1][j][z] = INF;
    dp[1][a[1]][1] = 0;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i] == 0)
        for (int z = 1; z <= k; z++) {
          dp[i][j][z] = dp[i - 1][j][z] + p[i][j];
          if (z > 1)
            for (int l = 1; l <= m; l++) {
              if (l == j) continue;
              dp[i][j][z] = min(dp[i][j][z], dp[i - 1][l][z - 1] + p[i][j]);
            }
        }
      else {
        if (j != a[i])
          for (int z = 1; z <= k; z++) dp[i][j][z] = INF;
        else
          for (int z = 1; z <= k; z++) {
            dp[i][j][z] = dp[i - 1][j][z];
            if (z > 1)
              for (int l = 1; l <= m; l++) {
                if (l == j) continue;
                dp[i][j][z] = min(dp[i][j][z], dp[i - 1][l][z - 1]);
              }
          }
      }
    }
  }
  long long ans = INF;
  for (int i = 1; i <= m; i++) ans = min(ans, dp[n][i][k]);
  if (ans == INF)
    printf("-1\n");
  else
    printf("%I64d\n", ans);
  return 0;
}
