#include using namespace std; #define INF 1e9 #define FOR(i,a,b) for(int i=a;i>N>>C>>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]; memset(dp,0x3f,sizeof(dp)); rep(i,310)dp[1][i]=0; for(int i=0;i=0){ dp[T[i]][j]=min(dp[T[i]][j],dp[S[i]][j-Y[i]]+M[i]); } } } int ans=INF; rep(i,C+1)ans=min(ans,dp[N][i]); if(ans<1e9)cout<