#include using namespace std; using Int = int_fast64_t; using Word = uint_fast64_t; using Int128 = __int128_t; using Word128 = __uint128_t; using VInt = vector; using VVI = vector; using VWord = vector; using VVW = vector; using VS = vector; using VVS = vector; using VB = vector; using VVB = vector; using PII = pair; using PWW = pair; using VPII = vector; using VPWW = vector; #define SZ(x) ((Int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define rep(i,n) for(Int i=0, i##_len=(n); i> n >> c >> v; VInt s(v); rep(i,v) { cin >> s[i]; s[i]--; } VVI t(n), y(n), m(n); Int x; rep(i,v) { cin >> x; x--; t[s[i]].pb(x); } rep(i,v) { cin >> x; y[s[i]].pb(x); } rep(i,v) { cin >> x; m[s[i]].pb(x); } VVI dp(n, VInt(c + 1, inf)); dp[0][c] = 0; rep(i,n) { rep(j,(c + 1)) { if (dp[i][j] == inf) continue; for (Int k = 0; k < SZ(t[i]); k++) { Int to = t[i][k], cost = j - y[i][k]; if (cost >= 0) { dp[to][cost] = min(dp[to][cost], dp[i][j] + m[i][k]); } } } } Int ans = inf; rep(i,(c + 1)) ans = min(ans, dp[n - 1][i]); if (ans == inf) cout << "-1\n"; else cout << ans << '\n'; return 0; }