#include <bits/stdc++.h>
using namespace std;
long long p[105][105], dp[105][105][105];
int c[105];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = (int)1; i <= (int)n; i++) cin >> c[i];
  for (int i = (int)1; i <= (int)n; i++)
    for (int j = (int)1; j <= (int)m; j++) cin >> p[i][j];
  for (int i = (int)0; i <= (int)n; i++)
    for (int j = (int)0; j <= (int)k; j++)
      for (int l = (int)0; l <= (int)m; l++) dp[i][j][l] = 1e18;
  for (int i = (int)1; i <= (int)m; i++) dp[0][0][i] = 0;
  for (int i = (int)1; i <= (int)n; i++) {
    for (int j = (int)1; j <= (int)k; j++) {
      for (int l = (int)1; l <= (int)m; l++) {
        dp[i][j][l] = (dp[i - 1][j][l]);
        for (int second = (int)1; second <= (int)m; second++)
          if (second != l)
            dp[i][j][l] = min(dp[i][j][l], dp[i - 1][j - 1][second]);
        if (i == 1) dp[i][j][l] = min(dp[i][j][l], dp[i - 1][j - 1][l]);
        if (c[i] == 0)
          dp[i][j][l] += p[i][l];
        else if (c[i] != l)
          dp[i][j][l] = 1e18;
      }
    }
  }
  long long ans = 1e18;
  for (int i = (int)1; i <= (int)m; i++) ans = min(dp[n][k][i], ans);
  if (ans >= 1e18) ans = -1;
  cout << ans << endl;
  return 0;
}
