#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for(int i = 0; i < (n); i++) #define per(i, n) for(int i = (n) - 1; i >= 0; i--) using ll = long long; #define vi vector #define vvi vector #define vl vector #define pii pair #define pll pair #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() constexpr int mod = 1000000007; using namespace std; template bool chmax(T &a, const U &b){ return a < b ? (a = b, 1) : 0; } template bool chmin(T &a, const U &b){ return a > b ? (a = b, 1) : 0; } template struct Edge { int from,to; T cost; int idx; Edge(){}; Edge(int f, int t, T c=1, int i=-1) : from(f), to(t), cost(c), idx(i){} Edge(int t) : to(t), from(-1), cost(1), idx(-1){} operator int() const{ return to; } bool operator<(const Edge &e){ return cost < e.cost; } }; template struct Graph : vector>> { Graph(){} Graph(const int &n) : vector>>(n){} void add_edge(int a, int b, T c=1, int i=-1){ (*this)[a].push_back({ a, b, c, i }); } }; using graph = Graph; int main(){ int n,C,m; cin >> n >> C >> m; vi s(m); rep(i, m) cin >> s[i]; graph root(n); rep(i, m){ int t; cin >> t; root[s[i]-1].push_back({ s[i]-1, t-1, -1, i }); } vi c(m), t(m); rep(i, m) cin >> c[i]; rep(i, m) cin >> t[i]; vvi dp(n, vi(C+1, mod)); dp[0][0] = 0; rep(i, n){ for(auto &x : root[i]){ rep(j, C){ if(c[x.idx]+j > C) break; chmin(dp[x][j + c[x.idx]], dp[i][j] + t[x.idx]); } } } int ans = mod; rep(i, C+1) chmin(ans, dp[n-1][i]); if(ans == mod) cout << "-1\n"; else cout << ans << "\n"; }