#include <bits/stdc++.h>
using namespace std;
inline long long powmod(long long x, long long n, long long _mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = (res * x) % _mod;
    x = (x * x) % _mod;
    n >>= 1;
  }
  return res;
}
const long long inf = 1e18;
int n, m, k;
int cost[105][105];
int color[105];
long long dp[105][105][105];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i < n + 1; ++i) {
    cin >> color[i];
  }
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < m + 1; ++j) {
      cin >> cost[i][j];
    }
  }
  for (int i = 0; i < 105; ++i) {
    for (int j = 0; j < 105; ++j) {
      for (int l = 0; l < 105; ++l) {
        dp[i][j][l] = inf;
      }
    }
  }
  if (color[1])
    dp[1][1][color[1]] = min(dp[1][1][color[1]], 0LL);
  else {
    for (int c = 1; c < m + 1; ++c) {
      dp[1][1][c] = cost[1][c];
    }
  }
  for (int i = 1; i < n + 1; ++i) {
    for (int k = 1; k < 105; ++k) {
      for (int c = 1; c < m + 1; ++c) {
        if (dp[i][k][c] >= inf) continue;
        for (int nc = 1; nc < m + 1; ++nc) {
          if (color[i + 1] == 0) {
            if (c == nc)
              dp[i + 1][k][nc] =
                  min(dp[i + 1][k][nc], dp[i][k][c] + cost[i + 1][nc]);
            else
              dp[i + 1][k + 1][nc] =
                  min(dp[i + 1][k + 1][nc], dp[i][k][c] + cost[i + 1][nc]);
          } else {
            if (c == color[i + 1])
              dp[i + 1][k][c] = min(dp[i + 1][k][c], dp[i][k][c]);
            else
              dp[i + 1][k + 1][color[i + 1]] =
                  min(dp[i + 1][k + 1][color[i + 1]], dp[i][k][c]);
          }
        }
      }
    }
  }
  long long ans = inf;
  for (int i = 1; i < m + 1; ++i) ans = min(ans, dp[n][k][i]);
  if (ans >= inf) ans = -1;
  cout << ans << '\n';
  return 0;
}
