#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 10;
const long long INF = 1e15;
const double EXP = 0.0001;
void files() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int c[MAXN];
int p[MAXN][MAXN];
long long dp[MAXN][MAXN][MAXN];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &p[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int d = 1; d <= k; d++) dp[i][j][d] = INF;
  for (int d = 1; d <= k; d++)
    for (int i = 1; i <= n; i++) {
      if (d > i) continue;
      if (c[i] == 0) {
        for (int j = 1; j <= m; j++) {
          dp[i][j][d] = min(dp[i][j][d], dp[i - 1][j][d] + p[i][j]);
          if (d > 1)
            for (int x = 1; x <= m; x++)
              if (x != j)
                dp[i][j][d] = min(dp[i][j][d], dp[i - 1][x][d - 1] + p[i][j]);
        }
      } else {
        for (int j = 1; j <= m; j++)
          if (j == c[i])
            dp[i][j][d] = min(dp[i][j][d], dp[i - 1][j][d]);
          else if (d > 1)
            dp[i][c[i]][d] = min(dp[i][c[i]][d], dp[i - 1][j][d - 1]);
      }
    }
  long long ans = INF;
  for (int i = 1; i <= m; i++) ans = min(ans, dp[n][i][k]);
  cout << (ans == INF ? -1 : ans);
  return 0;
}
