#include <bits/stdc++.h>
using namespace std;
int c[111];
int p[111][111];
long long dp[111][111][111];
const long long INF = 1e15;
void Min(long long &a, long long b) {
  if (b < a) {
    a = b;
  }
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d\n", &c[i]);
  }
  for (int i = 0; i <= 100; i++) {
    for (int j = 0; j <= 100; j++) {
      for (int q = 0; q <= 100; q++) {
        dp[i][j][q] = INF;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &p[i][j]);
      if (i == 1) {
        if (c[1] == 0) {
          dp[1][1][j] = p[1][j];
        }
        if (c[1] == j) {
          dp[1][1][j] = 0;
        }
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    if (c[i] == 0) {
      for (int j = 1; j <= k; j++) {
        for (int q = 1; q <= m; q++) {
          for (int w = 1; w <= m; w++) {
            if (q == w) {
              Min(dp[i][j][w], dp[i - 1][j][w] + p[i][w]);
            } else {
              Min(dp[i][j][w], dp[i - 1][j - 1][q] + p[i][w]);
            }
          }
        }
      }
    } else {
      for (int j = 1; j <= k; j++) {
        for (int q = 1; q <= m; q++) {
          if (c[i] == q) {
            Min(dp[i][j][c[i]], dp[i - 1][j][q]);
          } else {
            Min(dp[i][j][c[i]], dp[i - 1][j - 1][q]);
          }
        }
      }
    }
  }
  long long ans = INF;
  for (int i = 1; i <= m; i++) {
    Min(ans, dp[n][k][i]);
  }
  if (ans >= INF) {
    puts("-1");
  } else {
    printf("%I64d\n", ans);
  }
  return 0;
}
