#include"bits/stdc++.h" //#include using namespace std; #define print(x) cout<> n >> c >> v; rep(i, 0, v) { cin >> s[i] ; } rep(i, 0, v) { cin >> t[i]; } rep(i, 0, v) { cin >> y[i]; } rep(i, 0, v) { cin >> m[i]; } rep(i, 0, 51)rep(j, 0, 301)dp[i][j] = mod; dp[1][c] = 0; rep(i, 1, n + 1) { for (int j = c; j >= 0; j--) { if (dp[i][j] != mod) { rep(k, 0, v) { if (i == s[k] && j - y[k] >= 0) { dp[t[k]][j - y[k]] = min(dp[i][j] + m[k], dp[t[k]][j - y[k]]); } } } } } int ans = mod; rep(i, 0,301)ans = min(ans, dp[n][i]); if (ans >= mod) { print(-1); return 0; } print(ans); return 0; }