#include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-12;
const int N = 100 + 10, maxn = 10000 + 10, inf = 0x3f3f3f3f;
int c[N], p[N][N];
long long dp[N][N][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> c[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> p[i][j];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int u = 0; u <= k; u++) dp[i][j][u] = 1e15;
  if (!c[1]) {
    for (int i = 1; i <= m; i++) dp[1][i][1] = p[1][i];
  } else
    dp[1][c[1]][1] = 0;
  for (int i = 2; i <= n; i++) {
    if (c[i] != 0) {
      for (int j = 1; j <= m; j++) {
        for (int u = 1; u <= i && u <= k; u++) {
          if (j == c[i])
            dp[i][c[i]][u] = min(dp[i][c[i]][u], dp[i - 1][c[i]][u]);
          else
            dp[i][c[i]][u] = min(dp[i][c[i]][u], dp[i - 1][j][u - 1]);
        }
      }
    } else {
      for (int j = 1; j <= m; j++) {
        for (int u = 1; u <= m; u++) {
          for (int v = 1; v <= k && v <= i; v++) {
            if (j == u)
              dp[i][j][v] = min(dp[i][j][v], dp[i - 1][j][v] + p[i][j]);
            else
              dp[i][j][v] = min(dp[i][j][v], dp[i - 1][u][v - 1] + p[i][j]);
          }
        }
      }
    }
  }
  long long ans = 1e15;
  for (int i = 1; i <= m; i++) ans = min(ans, dp[n][i][k]);
  if (ans >= 1e15)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
