#include <bits/stdc++.h>
using namespace std;
long long dp[105][105][105], n, m, k, a[105], d[105][105];
int main() {
  long long i, j, p, mn, t;
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> d[i][j];
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++)
      for (p = 0; p <= k; p++) dp[i][j][p] = 1e18;
  if (a[1])
    dp[1][a[1]][1] = 0;
  else {
    for (i = 1; i <= m; i++) dp[1][i][1] = d[1][i];
  }
  for (i = 2; i <= n; i++)
    if (a[i]) {
      for (p = 1; p <= k; p++) {
        mn = 1e18;
        for (t = 1; t <= m; t++)
          if (t != a[i])
            mn = min(mn, dp[i - 1][t][p - 1]);
          else
            mn = min(mn, dp[i - 1][t][p]);
        dp[i][a[i]][p] = mn;
      }
    } else {
      for (j = 1; j <= m; j++)
        for (p = 1; p <= k; p++) {
          mn = 1e18;
          for (t = 1; t <= m; t++)
            if (t != j)
              mn = min(mn, dp[i - 1][t][p - 1]);
            else
              mn = min(mn, dp[i - 1][t][p]);
          dp[i][j][p] = mn + d[i][j];
        }
    }
  mn = 1e18;
  for (i = 1; i <= m; i++) mn = min(mn, dp[n][i][k]);
  if (mn == 1e18)
    cout << "-1\n";
  else
    cout << mn << "\n";
  return 0;
}
