#include using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) static const int INF = 1e8; int dp[51][301]; int main(void){ int n,c,v; cin >> n >> c >> v; vector 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]; rep(i,51)rep(j,301) dp[i][j] = INF; dp[1][c] = 0; for(int i = 1; i <= n ;i++){ for(int j= c; j >= 0; --j){ if(dp[i][j] != INF){ for(int k = 0; k = 0){ dp[t[k]][j-y[k]] = min(dp[i][j] + m[k],dp[t[k]][j-y[k]]); } } } } } int ans = INF; rep(i,301) ans = min(ans,dp[n][i]); if(ans >= INF){ cout << -1 << endl; return 0; } cout << ans << endl; return 0; }