#include <bits/stdc++.h>
using namespace std;
long long dp[101][101][101];
int main() {
  int n, m, r;
  cin >> n >> m >> r;
  int c[n];
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      for (int k = 0; k < 101; k++) {
        dp[i][j][k] = 100000000000000;
      }
    }
  }
  long long arr[101][101];
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> arr[i][j];
      if (c[i]) {
        if (j != c[i])
          arr[i][j] = 100000000000000;
        else
          arr[i][j] = 0;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    dp[0][1][i] = arr[0][i];
  }
  for (int i = 1; i < n; i++) {
    int z = c[i];
    for (int j = 1; j <= r; j++) {
      for (int k = 1; k <= m; k++) {
        dp[i][j][k] = dp[i - 1][j][k] + arr[i][k];
        for (int y = 1; y <= m; y++) {
          if (y == k) continue;
          dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - 1][y] + arr[i][k]);
        }
      }
    }
  }
  long long out = 100000000000000;
  for (int i = 1; i <= m; i++) {
    out = min(out, dp[n - 1][r][i]);
  }
  if (out < 100000000000000) {
    cout << out;
  } else {
    cout << -1;
  }
  return 0;
}
