#include <bits/stdc++.h>
using namespace std;
const long long N = 105;
const long long oo = (long long)1e18 + 7;
long long n;
long long m;
long long seg_target;
long long a[N];
long long c[N][N];
long long dp[N][N][N];
int main() {
  scanf("%I64d %I64d %I64d", &n, &m, &seg_target);
  for (long long i = 1, _b = (n); i <= _b; i++) scanf("%I64d", &a[i]);
  for (long long i = 1, _b = (n); i <= _b; i++) {
    for (long long color = 1, _b = (m); color <= _b; color++) {
      scanf("%I64d", &c[i][color]);
    }
  }
  for (long long i = 0, _b = (n); i <= _b; i++) {
    for (long long color = 0, _b = (m); color <= _b; color++) {
      for (long long numSeg = 0, _b = (n); numSeg <= _b; numSeg++) {
        dp[i][color][numSeg] = oo;
      }
    }
  }
  if (a[1] == 0) {
    for (long long color = 1, _b = (m); color <= _b; color++) {
      dp[1][color][1] = c[1][color];
    }
  } else {
    dp[1][a[1]][1] = 0;
  }
  for (long long i = 2, _b = (n); i <= _b; i++) {
    if (a[i] == 0) {
      for (long long color = 1, _b = (m); color <= _b; color++) {
        for (long long numSeg = 1, _b = (n); numSeg <= _b; numSeg++) {
          for (long long preColor = 1, _b = (m); preColor <= _b; preColor++) {
            if (color == preColor) {
              dp[i][color][numSeg] =
                  min(dp[i][color][numSeg],
                      dp[i - 1][preColor][numSeg] + c[i][color]);
            } else {
              dp[i][color][numSeg] =
                  min(dp[i][color][numSeg],
                      dp[i - 1][preColor][numSeg - 1] + c[i][color]);
            }
          }
        }
      }
    } else {
      for (long long numSeg = 1, _b = (n); numSeg <= _b; numSeg++) {
        for (long long preColor = 1, _b = (m); preColor <= _b; preColor++) {
          long long color = a[i];
          if (color == preColor) {
            dp[i][color][numSeg] =
                min(dp[i][color][numSeg], dp[i - 1][preColor][numSeg]);
          } else {
            dp[i][color][numSeg] =
                min(dp[i][color][numSeg], dp[i - 1][preColor][numSeg - 1]);
          }
        }
      }
    }
  }
  long long res = oo;
  for (long long color = 1, _b = (m); color <= _b; color++) {
    if (a[n] != 0 && a[n] != color) continue;
    res = min(res, dp[n][color][seg_target]);
  }
  if (res == oo) return cout << -1, 0;
  cout << res;
  return 0;
}
