#include #define rep(i, n) for(int i=0;i<(int)(n);++i) #define rep1(i, n) for(int i=1;i<=(int)(n);++i) #define irep(i, a, n) for(int i=a;i<(int)(n);++i) #define rrep(i, n) for(int i=(int)(n)-1;i>=0;--i) #define rrep1(i, n) for(int i=(int)(n);i>=1;--i) #define allrep(V, v) for(auto&& V:v) #define all(x) (x).begin(),(x).end() typedef long long lint; const int INF=1<<29; const double EPS=1e-9; using namespace std; int n,c,v; vector> cost,zeit; int solve(int town, int costlimit) { if(town == 1) return 0; int mini=INF; rep1(i,town-1){ if(cost[town-i][town]!=0 && (costlimit-cost[town-i][town])>=0){ mini=min(mini,solve(town-i,costlimit-cost[town-i][town])+zeit[town-i][town]); } } return mini; } int main (void) { cin>>n>>c>>v; vector s(v+1),t(v+1),y(v+1),m(v+1); rep1(i,v) cin>>s[i]; rep1(i,v) cin>>t[i]; rep1(i,v) cin>>y[i]; rep1(i,v) cin>>m[i]; cost.resize(n+1,vector(n+1)); zeit.resize(n+1,vector(n+1)); rep1(i,v){ cost[s[i]][t[i]]=y[i]; zeit[s[i]][t[i]]=m[i]; } int ans=solve(n,c); cout << (ans