#include #define rep(i,n) for (int i = 0; i < (n); ++i) #define chmax(a, b) a = max(a, b); #define chmin(a, b) a = min(a, b); using namespace std; using ll = long long; using P = pair; using VI = vector; using VVI = vector; const int INF = 1001001001; struct Edge { int s; int t; int y; int m; }; int main() { int n, c, v; cin >> n >> c >> v; vector e(v); rep(i, v) cin >> e[i].s, e[i].s--; rep(i, v) cin >> e[i].t, e[i].t--; rep(i, v) cin >> e[i].y; rep(i, v) cin >> e[i].m; VVI dp(n, VI(c+1, INF)); dp[0][0] = 0; rep(i, n) { rep(k, v) if (e[k].s == i) { int dest = e[k].t, cost = e[k].y; rep(j, c) if (j + cost <= c) chmin(dp[dest][j+cost], dp[i][j] + e[k].m); } } int ans = INF; rep(j, c+1) chmin(ans, dp[n-1][j]); if (ans == INF) ans = -1; cout << ans << endl; }