#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, k, k1, l, n, m, ans = 0, temp = 0, p;
  cin >> n >> m >> k1;
  long long a[n + 2][m + 2][n + 2];
  memset(a, 0, sizeof(a));
  long long mat[n + 1];
  for (i = 1; i <= n; i++) cin >> mat[i];
  long long col[n + 1][m + 1];
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> col[i][j];
  for (i = n; i > 0; i--) {
    if (mat[i] != 0) {
      for (j = 1; j <= m; j++) {
        if (j == mat[i]) {
          l = n - i + 1;
          for (k = 1; k <= l; k++) {
            if (k == 1) {
              a[i][j][k] = a[i + 1][j][1];
              continue;
            }
            ans = 9e12;
            for (p = 1; p <= m; p++) {
              if (p == j) continue;
              ans = min(ans, a[i + 1][p][k - 1]);
            }
            if (k != l) ans = min(ans, a[i + 1][j][k]);
            a[i][j][k] = ans;
          }
        } else {
          for (k = 1; k <= n; k++) a[i][j][k] = 9e12;
        }
      }
    } else {
      for (j = 1; j <= m; j++) {
        l = n - i + 1;
        for (k = 1; k <= l; k++) {
          if (k == 1) {
            a[i][j][k] = col[i][j] + a[i + 1][j][1];
            continue;
          }
          ans = 9e12;
          for (p = 1; p <= m; p++) {
            if (p == j) continue;
            ans = min(ans, a[i + 1][p][k - 1]);
          }
          if (k != l) ans = min(ans, a[i + 1][j][k]);
          a[i][j][k] = col[i][j] + ans;
        }
      }
    }
  }
  ans = 9e12;
  for (i = 1; i <= m; i++) {
    ans = min(ans, a[1][i][k1]);
  }
  if (ans >= 9e12)
    cout << -1;
  else
    cout << ans;
  return 0;
}
