#include <bits/stdc++.h>
using namespace std;
const long long mX = 1e18;
const int mN = 102;
long long n, m, k, c[mN], p[mN][mN], f[mN][mN][mN], h;
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 j = 1; j <= m; j++) cin >> p[i][j];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= k + 1; j++)
      for (int z = 0; z <= m + 1; z++) f[i][j][z] = mX;
  if (c[0] == 0)
    for (int z = 1; z <= m; z++) f[0][1][z] = p[0][z];
  if (c[0] != 0) f[0][1][c[0]] = 0;
  for (int i = 0; i < n; i++) {
    if (c[i + 1] != 0) {
      for (int j = 1; j <= k; j++) {
        f[i + 1][j][c[i + 1]] = min(f[i + 1][j][c[i + 1]], f[i][j][c[i + 1]]);
        for (int z = 1; z <= m; z++)
          if (z != c[i + 1])
            f[i + 1][j][c[i + 1]] = min(f[i + 1][j][c[i + 1]], f[i][j - 1][z]);
      }
      continue;
    }
    for (int j = 1; j <= k; j++)
      for (int z = 1; z <= m; z++) {
        for (int z2 = 1; z2 <= m; z2++) {
          if (z == z2)
            h = 1;
          else
            h = 0;
          f[i + 1][j + 1 - h][z2] =
              min(f[i + 1][j + 1 - h][z2], f[i][j][z] + p[i + 1][z2]);
        }
      }
  }
  long long ans = 1e18;
  for (int z = 1; z <= m; z++) ans = min(ans, f[n - 1][k][z]);
  if (ans == 1e18)
    cout << -1 << endl;
  else
    cout << ans << endl;
}
