#include <bits/stdc++.h>
using namespace std;
long long dp[105][105][105];
long long p[105][105];
long long c[105];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long n, m, K, k, i, j, num;
    cin >> n >> m >> K;
    for (i = 1; i <= n; i++) cin >> c[i];
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) cin >> p[i][j];
    memset(dp, -1, sizeof dp);
    if (c[1] != 0)
      dp[1][c[1]][1] = 0;
    else
      for (j = 1; j <= m; j++) dp[1][j][1] = p[1][j];
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        for (k = 1; k <= K; k++) {
          if (dp[i][j][k] != -1) {
            if (c[i + 1] != 0) {
              if (j == c[i + 1]) {
                if (dp[i + 1][j][k] == -1)
                  dp[i + 1][j][k] = dp[i][j][k];
                else
                  dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
              } else {
                if (dp[i + 1][c[i + 1]][k + 1] == -1)
                  dp[i + 1][c[i + 1]][k + 1] = dp[i][j][k];
                else
                  dp[i + 1][c[i + 1]][k + 1] =
                      min(dp[i + 1][c[i + 1]][k + 1], dp[i][j][k]);
              }
            } else {
              for (int col = 1; col <= m; col++) {
                if (col == j) {
                  if (dp[i + 1][j][k] == -1)
                    dp[i + 1][j][k] = dp[i][j][k] + p[i + 1][j];
                  else
                    dp[i + 1][j][k] =
                        min(dp[i + 1][j][k], dp[i][j][k] + p[i + 1][j]);
                } else {
                  if (dp[i + 1][col][k + 1] == -1)
                    dp[i + 1][col][k + 1] = dp[i][j][k] + p[i + 1][col];
                  else
                    dp[i + 1][col][k + 1] =
                        min(dp[i][j][k] + p[i + 1][col], dp[i + 1][col][k + 1]);
                }
              }
            }
          }
        }
      }
    }
    long long mn = 100000000000007;
    for (i = 1; i <= m; i++)
      if (dp[n][i][K] != -1) mn = min(mn, dp[n][i][K]);
    if (mn == 100000000000007)
      cout << "-1";
    else
      cout << mn;
  }
  return 0;
}
