#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const int N = 110;
int n, m, k;
long long dp[N][N][N];
int p[N][N], c[N];
int main() {
  iostream ::sync_with_stdio(false);
  cin.tie(NULL);
  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 + 1; i++)
    for (int j = 0; j <= k + 1; j++)
      for (int col = 0; col <= m + 1; col++) dp[i][j][col] = INF;
  for (int col = 1; col <= m; col++) dp[0][0][col] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= k; j++) {
      if (c[i] != 0) {
        dp[i][j][c[i]] = min(dp[i][j][c[i]], dp[i - 1][j][c[i]]);
        for (int col = 1; col <= m; col++)
          if (col != c[i] || i == 1)
            dp[i][j][c[i]] = min(dp[i][j][c[i]], dp[i - 1][j - 1][col]);
        continue;
      }
      for (int col = 1; col <= m; col++)
        dp[i][j][col] = min(dp[i][j][col], dp[i - 1][j][col] + p[i][col]);
      for (int c1 = 1; c1 <= m; c1++)
        for (int c2 = 1; c2 <= m; c2++)
          if (c1 != c2 || i == 1)
            dp[i][j][c1] = min(dp[i][j][c1], dp[i - 1][j - 1][c2] + p[i][c1]);
    }
  long long ans = INF;
  for (int col = 1; col <= m; col++) ans = min(ans, dp[n][k][col]);
  if (ans == INF) ans = -1;
  cout << ans << "\n";
  return 0;
}
