#include #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)n;++i) #define each(a, b) for(auto (a): (b)) #define all(v) (v).begin(),(v).end() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<P; const int MAX_N = 55; const int MAX_C = 305; struct edge { int to,cost,tm; }; int dp[MAX_N][MAX_C]; vector G[MAX_N]; int main() { cin.tie(0); ios::sync_with_stdio(false); 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,v){ G[s[i]-1].pb((edge){t[i]-1,y[i],m[i]}); } rep(i,n+1){ rep(j,c+1){ dp[i][j] = INF; } } dp[0][c] = 0; rep(i,n){ rep(j,c+1){ rep(k,G[i].size()){ if(j >= G[i][k].cost){ dp[G[i][k].to][j-G[i][k].cost] = min(dp[G[i][k].to][j-G[i][k].cost],dp[i][j]+G[i][k].tm); } } } } int ans = INF; rep(i,c+1){ ans = min(ans,dp[n-1][i]); } if(ans == INF){ cout << "-1\n"; }else{ cout << ans << endl; } return 0; }