#include <bits/stdc++.h>
using namespace std;
long long price[105][105];
long long dp[105][105][105];
long long num[105];
int main() {
  long long n, mm, kk;
  while (cin >> n >> mm >> kk) {
    long long p = 1;
    kk++;
    for (long long i = 0; i < n; i++) {
      cin >> num[i];
      num[i]--;
    }
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < mm; j++) cin >> price[i][j];
    }
    if (mm == 1 && kk != 2) {
      cout << "-1" << endl;
      continue;
    }
    long long minl = 1, maxl = 0, temp = -1, temp2 = 0, l = -1, r = -1;
    if (mm == 2) {
      for (long long i = 0; i < n; i++) {
        if (num[i] == -1) {
          if (i == 0 && num[i] == -1) l = -2;
          if (i == n - 1 && num[i] == -1) r = -2;
          if (i > 0 && num[i - 1] != -1) l = num[i - 1];
          if (i < n - 1 && num[i + 1] != -1) r = num[i - 1];
          temp2++;
        }
        if (temp != -1 && num[i] != -1) {
          if (temp != num[i]) minl++;
        }
        if (num[i] != -1) temp = num[i];
        if (l != -1 && r != -1) {
          if (l == r)
            maxl = maxl + (temp2 % 2 == 0 ? temp2 - 1 : temp2);
          else
            maxl = maxl + (temp2 % 2 == 0 ? temp2 : temp2 - 1);
          l = r = -1;
          temp2 = 0;
        }
        if ((l == -2 && r != -1) || (l != -1 && r == -2)) {
          l = r = -1;
          maxl += temp2;
          temp2 = 0;
        }
        if (i > 0 && num[i] != -1 && num[i - 1] != num[i]) maxl++;
        if (i == 0 && num[i] != -1) maxl++;
      }
    } else {
      for (long long i = 0; i < n; i++) {
        if (num[i] == -1) {
          temp2++;
          continue;
        }
        if (temp != -1) {
          if (temp != num[i]) minl++;
        }
        temp = num[i];
        if (i > 0 && num[i] != -1 && num[i - 1] != num[i]) maxl++;
        if (i == 0 && num[i] != -1) maxl++;
      }
      maxl += temp2;
    }
    if (minl > kk - 1 || maxl < kk - 1) {
      cout << "-1" << endl;
      continue;
    }
    memset(dp, -1, sizeof(dp));
    if (num[0] == -1)
      for (long long i = 0; i < mm; i++) dp[0][i][1] = price[0][i];
    else
      dp[0][num[0]][1] = 0;
    for (long long i = 1; i < n; i++) {
      for (long long j = (num[i - 1] == -1 ? 0 : num[i - 1]);
           j < (num[i - 1] == -1 ? mm : num[i - 1] + 1); j++) {
        for (long long k = (num[i] == -1 ? 0 : num[i]);
             k < (num[i] == -1 ? mm : num[i] + 1); k++) {
          for (long long m = 1; m < kk; m++) {
            if (dp[i - 1][j][m] == -1) continue;
            if (num[i] != -1) {
              if (k == j)
                dp[i][k][m] =
                    (dp[i][k][m] == -1 ? dp[i - 1][j][m]
                                       : min(dp[i][k][m], dp[i - 1][j][m]));
              else
                dp[i][k][m + 1] = (dp[i][k][m + 1] == -1
                                       ? dp[i - 1][j][m]
                                       : min(dp[i][k][m + 1], dp[i - 1][j][m]));
            } else {
              if (k == j)
                dp[i][k][m] =
                    (dp[i][k][m] == -1
                         ? dp[i - 1][j][m] + price[i][k]
                         : min(dp[i][k][m], dp[i - 1][j][m] + price[i][k]));
              else
                dp[i][k][m + 1] =
                    (dp[i][k][m + 1] == -1
                         ? dp[i - 1][j][m] + price[i][k]
                         : min(dp[i][k][m + 1], dp[i - 1][j][m] + price[i][k]));
            }
          }
        }
      }
    }
    long long minans = 0;
    for (long long i = 0; i < mm; i++) {
      if (dp[n - 1][i][kk - 1] == -1) continue;
      if (minans == 0)
        minans = dp[n - 1][i][kk - 1];
      else
        minans = min(minans, dp[n - 1][i][kk - 1]);
    }
    cout << minans << endl;
  }
}
