#include <bits/stdc++.h>
using namespace std;
template <class T>
void print_array(T a[], int size) {
  for (int i = 0; i < size; i++) cout << a[i] << " ";
  cout << endl;
}
template <class T>
void print_array_v(T &a) {
  int size = a.size();
  for (int i = 0; i < size; i++) cout << a[i] << " ";
  cout << endl;
}
long long int a[501][501];
long long int c[501];
long long int dp[105][105][105];
long long int mini[105][105];
long long int minia[105][105];
int main() {
  long long int i, j, val1, val2;
  long long int n, m, k;
  cin >> n >> m >> k;
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) cin >> a[i][j];
  for (i = 0; i < 105; i++)
    for (j = 0; j < 105; j++)
      for (val1 = 0; val1 < 105; val1++) dp[i][j][val1] = 1e18;
  for (j = 0; j < m; j++)
    for (val1 = 0; val1 <= k + 1; val1++) minia[j][val1] = 1e18;
  if (c[0] == 0) {
    for (j = 0; j < m; j++) {
      dp[0][j][1] = a[0][j];
      minia[j][1] = min(minia[j][1], dp[0][j][1]);
    }
  } else
    dp[0][c[0] - 1][1] = 0, minia[c[0] - 1][1] =
                                min(minia[c[0] - 1][1], dp[0][c[0] - 1][1]);
  for (i = 1; i < n; i++) {
    for (val1 = 1; val1 <= k + 1; val1++) {
      long long int one = 1e18, two = 1e18;
      for (j = 0; j < m; j++) {
        mini[j][val1] = one;
        one = min(one, minia[j][val1]);
      }
      for (j = m - 1; j >= 0; j--) {
        mini[j][val1] = min(mini[j][val1], two);
        two = min(two, minia[j][val1]);
      }
    }
    for (j = 0; j < m; j++)
      for (val1 = 0; val1 <= k + 1; val1++) minia[j][val1] = 1e18;
    for (j = 0; j < m; j++) {
      for (val1 = 1; val1 <= k; val1++) {
        if (c[i] != 0) {
          if (j == c[i] - 1) {
            dp[i][j][val1] = min(dp[i][j][val1], dp[i - 1][j][val1]);
            minia[j][val1] = min(minia[j][val1], dp[i][j][val1]);
          } else {
            dp[i][c[i] - 1][val1 + 1] =
                min(dp[i][c[i] - 1][val1 + 1], dp[i - 1][j][val1]);
            minia[c[i] - 1][val1 + 1] =
                min(minia[c[i] - 1][val1 + 1], dp[i][c[i] - 1][val1 + 1]);
          }
        } else {
          dp[i][j][val1] = min(dp[i][j][val1], dp[i - 1][j][val1] + a[i][j]);
          dp[i][j][val1 + 1] = min(dp[i][j][val1 + 1], a[i][j] + mini[j][val1]);
          minia[j][val1 + 1] = min(minia[j][val1 + 1], dp[i][j][val1 + 1]);
          minia[j][val1] = min(minia[j][val1], dp[i][j][val1]);
        }
      }
    }
  }
  long long int ans = 1e18;
  for (j = 0; j < m; j++) ans = min(ans, dp[n - 1][j][k]);
  if (ans == 1000000000000000000) ans = -1;
  cout << ans << endl;
  return 0;
}
