#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1LL << 45;
const int N = 120;
long long i, j, k, l, n, m, p, a[N], b[N][N], dp[N][N][N], ans = MAX;
int main() {
  cin >> n >> m >> p;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> b[i][j];
  for (i = 0; i < N; i++)
    for (j = 0; j < N; j++)
      for (k = 0; k < N; k++) dp[i][j][k] = MAX;
  if (a[1] == 0)
    for (i = 1; i <= m; i++) dp[1][i][1] = b[1][i];
  else
    dp[1][a[1]][1] = 0;
  for (i = 2; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      for (k = 1; k <= m; k++) {
        if (a[i] != 0 and k != a[i]) continue;
        if (a[i] != 0) b[i][k] = 0;
        for (l = 1; l <= p; l++) {
          if (k == j)
            dp[i][k][l] = min(dp[i][k][l], dp[i - 1][j][l] + b[i][k]);
          else
            dp[i][k][l] = min(dp[i][k][l], dp[i - 1][j][l - 1] + b[i][k]);
        }
      }
    }
  }
  for (i = 1; i <= m; i++) ans = min(ans, dp[n][i][p]);
  if (ans == MAX) ans = -1;
  cout << ans;
}
