#include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template using V = vector; template using VV = V>; template using VVV = V>; template using VVVV = VV>; #define rep(i,n) for(ll i=0ll;i void chmin(T& t, const U& u) { if (t > u) t = u; } template void chmax(T& t, const U& u) { if (t < u) t = u; } // cin.tie(nullptr); // ios::sync_with_stdio(false); // cout << fixed << setprecision(20); void solve(){ ll n,c,v; cin >> n >> c >> v; V s(v), t(v), y(v), m(v); rep(i,v) cin >> s[i]; rep(i,v) cin >> t[i]; rep(i,v) cin >> y[i]; rep(i,v) cin >> m[i]; VV> G(n); rep(i,v) G[s[i]-1].eb(t[i]-1, y[i], m[i]); VV dist(n, V(c+1, INF)); dist[0][c] = 0; set> st; st.insert({0, 0, c}); while(!st.empty()){ auto[d, nd, c] = *st.begin(); st.erase(st.begin()); if(d != dist[nd][c]) continue; for(auto[to, y, m]:G[nd]) if(c >= y && dist[to][c-y] > d+m){ dist[to][c-y] = d+m; st.insert({d+m, to, c-y}); } } ll ans = INF; rep(i,c+1) chmin(ans, dist[n-1][i]); if(ans == INF) ans = -1; cout << ans << endl; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int t=1; // cin >> t; rep(i,t) solve(); }