#include <bits/stdc++.h>
using namespace std;
int n, m, k;
long long dp[123][123][123], a[123], col[123][123];
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> col[i][j];
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int t = 1; t <= k; t++) dp[i][j][t] = 1000000000000000001;
  if (a[1] == 0) {
    for (int i = 1; i <= m; i++) {
      dp[1][i][1] = col[1][i];
    }
  } else {
    dp[1][a[1]][1] = 0;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int t = 1; t <= k; t++) {
        if (dp[i][j][t] != 1000000000000000001) {
          if (a[i + 1] == 0) {
            for (int jj = 1; jj <= m; jj++) {
              if (j == jj) {
                dp[i + 1][j][t] =
                    min(dp[i + 1][j][t], dp[i][j][t] + col[i + 1][j]);
              } else
                dp[i + 1][jj][t + 1] =
                    min(dp[i + 1][jj][t + 1], dp[i][j][t] + col[i + 1][jj]);
            }
          } else {
            if (j == a[i + 1])
              dp[i + 1][a[i + 1]][t] = min(dp[i + 1][a[i + 1]][t], dp[i][j][t]);
            else
              dp[i + 1][a[i + 1]][t + 1] =
                  min(dp[i + 1][a[i + 1]][t + 1], dp[i][j][t]);
          }
        }
      }
    }
  }
  long long mn = 1000000000000000001;
  for (int j = 1; j <= m; j++) {
    mn = min(mn, dp[n][j][k]);
  }
  if (mn == 1000000000000000001)
    cout << -1;
  else
    cout << mn;
  return 0;
}
