#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,C,V; cin >> N >> C >> V; vector S(V),T(V),Y(V),M(V); rep(i,V){ cin >> S[i]; S[i]--; } rep(i,V){ cin >> T[i]; T[i]--; } rep(i,V) cin >> Y[i]; rep(i,V) cin >> M[i]; vector> e(N); rep(i,V) e[S[i]].emplace_back(i); vector> dp(N, vector (C + 1, 1e9)); dp[0][C] = 0; rep(i,N)for(int j : e[i])for(int k=Y[j];k<=C;k++){ dp[T[j]][k-Y[j]] = min(dp[T[j]][k-Y[j]], dp[i][k] + M[j]); } int ans = 1e9; rep(i,C+1) ans = min(ans, dp[N-1][i]); cout << (ans==1e9?-1:ans) << '\n'; }