#include using namespace std; #define MAX 1000000000 int main() { int n, c, v; cin >> n >> c >> v; vector s(v),t(v),y(v),m(v); for (int i = 0;i < v;i++) { cin >> s[i]; s[i]--; } for (int i = 0;i < v;i++) { cin >> t[i]; t[i]--; } for (int i = 0;i < v;i++) { cin >> y[i]; } for (int i = 0;i < v;i++) { cin >> m[i]; } vector>> e(n); for (int i = 0;i < v;i++) { e[s[i]].push_back(make_tuple(t[i], y[i], m[i])); } vector> dp(n, vector(c + 1, MAX)); dp[0][0] = 0; for (int i = 0;i < n;i++) { for (int j = 0;j < c + 1;j++) { if (dp[i][j] == MAX) { continue; } for (auto k : e[i]) { int ni = get<0>(k); int nj = j + get<1>(k); int nd = dp[i][j] + get<2>(k); if (nj < c + 1) { dp[ni][nj] = min(dp[ni][nj], nd); } } } } int ans = MAX; for (int i = 0;i < c + 1;i++) { ans = min(ans, dp[n - 1][i]); } cout << ((ans==MAX) ? -1 : ans) << endl; return 0; }