#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
long long int dp[200][200][200];
long long int ar[200];
long long int color[200][200];
int main() {
  int test;
  int maxx = 0;
  int index = -1;
  int n, m, k;
  cin >> n >> m >> k;
  int i, j;
  int p = k;
  for (i = 1; i <= n; i++) {
    cin >> ar[i];
  }
  for (i = 0; i <= 100; i++) {
    for (j = 0; j <= 100; j++)
      for (k = 0; k <= 100; k++) dp[i][j][k] = 100000000007;
  }
  k = p;
  long long int a = 100000000007;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> color[i][j];
    }
  }
  int l;
  if (!ar[1]) {
    for (i = 1; i <= m; i++) {
      dp[1][i][1] = color[1][i];
    }
  } else
    dp[1][ar[1]][1] = 0;
  for (i = 1; i <= n; i++) {
    if (!ar[i])
      for (l = 1; l <= i; l++) {
        for (j = 1; j <= m; j++) {
          dp[i][j][l] = min(dp[i][j][l], (dp[i - 1][j][l] + color[i][j]));
          for (p = 1; p <= m; p++) {
            if (p != j)
              dp[i][j][l] =
                  min(dp[i][j][l], (dp[i - 1][p][l - 1] + color[i][j]));
          }
        }
      }
    else {
      for (l = 1; l <= i; l++) {
        dp[i][ar[i]][l] = min(dp[i][ar[i]][l], dp[i - 1][ar[i]][l]);
        for (j = 1; j <= m; j++)
          if (j != ar[i])
            dp[i][ar[i]][l] = min(dp[i][ar[i]][l], dp[i - 1][j][l - 1]);
      }
    }
  }
  a = dp[n][1][k];
  for (i = 2; i <= m; i++) a = min(a, dp[n][i][k]);
  if (a > 100000000000)
    cout << "-1" << endl;
  else
    cout << a << endl;
  return 0;
}
