#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int estadoInicial[101];
long long int custo[101][101];
long long int dp[101][101][101];
void init() {
  int i, j, l;
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++)
      for (l = 0; l <= k; l++) dp[i][j][l] = -1;
}
long long int solve(int i, int j, int p) {
  if (p > k) {
    return 1e+15;
  }
  if (dp[i][j][p] != -1) return dp[i][j][p];
  if (i == n) {
    if (p == k) return dp[i][j][p] = 0;
    return dp[i][j][p] = 1e+15;
  }
  if (estadoInicial[i + 1]) {
    dp[i][j][p] =
        solve(i + 1, estadoInicial[i + 1], p + (j != estadoInicial[i + 1]));
  } else {
    dp[i][j][p] = 1e+15;
    for (int c = 1; c <= m; c++) {
      dp[i][j][p] =
          min(dp[i][j][p], custo[i + 1][c] + solve(i + 1, c, p + (j != c)));
    }
  }
  return dp[i][j][p];
}
int main() {
  int i, j;
  cin >> n >> m >> k;
  init();
  for (i = 1; i <= n; i++) {
    cin >> estadoInicial[i];
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> custo[i][j];
    }
  }
  long long int resp = solve(0, 0, 0);
  if (resp >= 1e+15)
    cout << "-1" << endl;
  else
    cout << resp << endl;
}
