#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 1e18;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const int maxmat = 10;
const unsigned long long BASE = 31;
const int maxn = 105;
long long dp[maxn][maxn][maxn];
int a[maxn];
int p[maxn][maxn];
int main(int argc, char const *argv[]) {
  int N, M, K;
  cin >> N >> M >> K;
  for (int i = 1; i <= N; i++) scanf("%d", a + i);
  for (int i = 1; i <= N; i++)
    for (int k = 1; k <= M; k++) scanf("%d", &p[i][k]);
  for (int i = 1; i <= N; i++)
    for (int j = 0; j <= N; j++)
      for (int k = 1; k <= M; k++) dp[i][j][k] = INFF;
  memset(dp[0][0], 0, sizeof(dp[0][0]));
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i; j++) {
      for (int k = 1; k <= M; k++) {
        if (k == a[i]) {
          for (int l = 1; l <= M; l++) {
            if (k == l)
              dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][l]);
            else
              dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][l]);
          }
        } else if (!a[i]) {
          for (int l = 1; l <= M; l++) {
            if (k == l)
              dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j][l] + p[i][k]);
            else
              dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][l] + p[i][k]);
          }
        }
      }
    }
  }
  long long ans = INFF;
  if (a[N])
    ans = min(ans, dp[N][K][a[N]]);
  else {
    for (int k = 1; k <= M; k++) ans = min(ans, dp[N][K][k]);
  }
  if (ans == INFF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
