#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i) templatebool chmin(T&a,const T&b){return a>b?(a=b,true):false;} templatebool chmax(T&a,const T&b){return a o.dist; } int& ref() { return memo[pos][money]; } }; int S[1500], T[1500], Y[1500], M[1500]; struct E { int s, t, y, m; }; vector es[51]; int main2() { REP(i, 51) es[i].clear(); int N = nextInt(); int C = nextInt(); int V = nextInt(); REP(i, V) S[i] = nextInt(); REP(i, V) T[i] = nextInt(); REP(i, V) Y[i] = nextInt(); REP(i, V) M[i] = nextInt(); REP(i, V) { es[S[i]].push_back( (E){S[i], T[i], Y[i], M[i]} ); } const int INF = 987654321; REP(i, 51) REP(j, 310) memo[i][j] = INF; int ans = INF; priority_queue pq; pq.push( (State){1, 0, 0} ); memo[1][0] = 0; while (!pq.empty()) { State cur = pq.top(); pq.pop(); if (cur.dist != cur.ref()) continue; if (cur.pos == N) { ans = cur.dist; break; } for (E e : es[cur.pos]) { State next = (State) { e.t, cur.dist + e.m, cur.money + e.y }; if (next.money > C) continue; if (next.ref() <= next.dist) continue; next.ref() = next.dist; pq.push(next); } } if (ans >= INF / 2) ans = -1; cout << ans << endl; return 0; } int main() { for (;!cin.eof();cin>>ws) main2(); return 0; }