#include <bits/stdc++.h>
using namespace std;
long long n, m, k, c[111], p[111][111], dp[111][111][111];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int i = 0; i < n; i++)
    for (int q = 1; q <= m; q++) cin >> p[i][q];
  for (int i = 0; i < n; i++)
    for (int q = 0; q <= k; q++)
      for (int w = 0; w <= m; w++) dp[i][q][w] = 111111111111111111LL;
  if (c[0] == 0)
    for (int i = 1; i <= m; i++) dp[0][1][i] = p[0][i];
  else
    dp[0][1][c[0]] = 0;
  for (int i = 1; i < n; i++)
    for (int q = 1; q <= k; q++) {
      if (c[i] != 0) {
        if (dp[i - 1][q][c[i]] != 111111111111111111LL)
          dp[i][q][c[i]] = dp[i - 1][q][c[i]];
        for (int w = 1; w <= m; w++)
          if (w != c[i])
            dp[i][q][c[i]] = min(dp[i][q][c[i]], dp[i - 1][q - 1][w]);
      } else {
        for (int w = 1; w <= m; w++) {
          if (dp[i - 1][q][w] != 111111111111111111LL)
            dp[i][q][w] = dp[i - 1][q][w] + p[i][w];
          for (int e = 1; e <= m; e++)
            if (e != w)
              dp[i][q][w] = min(dp[i][q][w], dp[i - 1][q - 1][e] + p[i][w]);
        }
      }
    }
  long long mn;
  if (c[n - 1] != 0)
    mn = dp[n - 1][k][c[n - 1]];
  else {
    mn = dp[n - 1][k][1];
    for (int i = 2; i <= m; i++) mn = min(mn, dp[n - 1][k][i]);
  }
  if (mn == 111111111111111111LL)
    cout << "-1";
  else
    cout << mn;
}
