#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 100;
const long long Inf = 1e13 + 7;
long long c[N], dp[N][N][N], p[N][N];
int main() {
  long long n, k, m, ans = Inf;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> c[i + 1];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> p[i + 1][j + 1];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= m; j++)
      for (int o = 0; o <= k; o++) dp[i][j][o] = Inf;
  for (int i = 1; i <= m; i++) {
    if (c[1] == 0)
      dp[1][i][1] = p[1][i];
    else
      dp[1][c[1]][1] = 0;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int o = 1; o <= i; o++) {
        if (c[i] == 0) {
          dp[i][j][o] = dp[i - 1][j][o] + p[i][j];
          for (int t = 1; t <= m; t++)
            if (t != j)
              dp[i][j][o] = min(dp[i][j][o], dp[i - 1][t][o - 1] + p[i][j]);
        } else if (j == c[i]) {
          dp[i][j][o] = dp[i - 1][j][o];
          for (int t = 1; t <= m; t++)
            if (t != c[i]) dp[i][j][o] = min(dp[i][j][o], dp[i - 1][t][o - 1]);
        }
      }
    }
  }
  for (int i = 1; i <= m; i++) ans = min(ans, dp[n][i][k]);
  cout << (ans == Inf ? -1 : ans) << endl;
}
