#include <bits/stdc++.h>
using namespace std;
bool checkBit(long long int n, long long int i) { return (n & (1LL << i)); }
long long int setBit(long long int n, long long int i) {
  return (n | (1LL << i));
}
long long int resetBit(long long int n, long long int i) {
  return (n & (~(1LL << i)));
}
const long long int MX = 1e18;
const long long int mod = 1e9 + 7;
long long int dp[103][103][103], val[103][103];
int col[103], n, k, m;
long long int fuck(int x, int seg, int prev) {
  if (x == n) {
    if (seg == k)
      return 0;
    else
      return MX;
  }
  if (seg > k) return MX;
  long long int &ret = dp[x][seg][prev];
  if (ret != -1) return ret;
  if (x == 0) {
    if (col[x] != 0) {
      return ret = fuck(x + 1, 1, col[x]);
    } else {
      long long int r1 = MX;
      for (int i = 0; i < m; i++) {
        r1 = min(r1, val[x][i] + fuck(x + 1, 1, i + 1));
      }
      return ret = r1;
    }
  } else {
    if (col[x] != 0) {
      if (col[x] != prev) {
        return ret = fuck(x + 1, seg + 1, col[x]);
      } else {
        return ret = fuck(x + 1, seg, col[x]);
      }
    } else {
      long long int r1 = MX;
      for (int i = 0; i < m; i++) {
        if (i + 1 != prev) {
          r1 = min(r1, val[x][i] + fuck(x + 1, seg + 1, i + 1));
        } else {
          r1 = min(r1, val[x][i] + fuck(x + 1, seg, prev));
        }
      }
      return ret = r1;
    }
  }
}
void solve() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    cin >> col[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> val[i][j];
    }
  }
  memset(dp, -1, sizeof(dp));
  long long int ans = fuck(0, 0, 0);
  if (ans == MX) ans = -1;
  cout << ans << "\n";
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
