#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long inf = LLONG_MAX;
long double pi = 3.1415926536;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, k, z = 1000000000000, c[101], p[101][101], dp[101][101][101];
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) cin >> c[i];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> p[i][j + 1];
    }
  }
  for (int i = 0; i < 101; ++i) {
    for (int j = 0; j < 101; ++j) {
      for (int x = 0; x < 101; ++x) {
        dp[i][j][x] = z;
      }
    }
  }
  if (c[n - 1]) {
    for (int i = 1; i <= m; i++) {
      if (i == c[n - 1])
        dp[n - 1][1][i] = 0;
      else
        dp[n - 1][1][i] = z;
      for (int j = 2; j <= k; j++) dp[n - 1][j][i] = z;
    }
  } else {
    for (int i = 1; i <= m; i++) {
      dp[n - 1][1][i] = p[n - 1][i];
      for (int j = 2; j <= k; j++) dp[n - 1][j][i] = z;
    }
  }
  for (int i = n - 2; i >= 0; i--) {
    if (c[i]) {
      for (int j = 1; j <= k; j++) {
        for (int x = 1; x <= m; x++) {
          if (x != c[i])
            dp[i][j][c[i]] = min(dp[i][j][c[i]], dp[i + 1][j - 1][x]);
          else
            dp[i][j][c[i]] = min(dp[i][j][c[i]], dp[i + 1][j][x]);
        }
      }
    } else {
      for (int j = 1; j <= k; j++) {
        for (int x = 1; x <= m; x++) {
          for (int y = 1; y <= m; y++) {
            if (x != y)
              dp[i][j][x] = min(dp[i][j][x], dp[i + 1][j - 1][y] + p[i][x]);
            else
              dp[i][j][x] = min(dp[i][j][x], dp[i + 1][j][x] + p[i][x]);
          }
        }
      }
    }
  }
  long long ans = z;
  for (int i = 1; i <= m; i++) ans = min(ans, dp[0][k][i]);
  if (ans > 100000000000)
    cout << -1 << '\n';
  else
    cout << ans << '\n';
  return 0;
}
