#include #include #include #include #include #define rep(i,a) for(int i=0;i<(a);++i) const int INF = std::numeric_limits::max()>>2; template void chmin( T &a, T b ) { if( a > b ) a = b; return; } struct edge { int to, cost, tim; edge( int to, int cost, int tim ) : to(to), cost(cost), tim(tim) {} }; int N, C, V; std::vector G[50]; int S[50], T[50], Y[50], M[50]; int main() { scanf( "%d%d%d", &N, &C, &V ); rep( i, N ) scanf( "%d", S+i ); rep( i, N ) scanf( "%d", T+i ); rep( i, N ) scanf( "%d", Y+i ); rep( i, N ) scanf( "%d", M+i ); rep( i, N ) G[S[i]-1].push_back( edge( T[i]-1, Y[i], M[i] ) ); std::vector > dp( 50, std::vector( C+1, INF ) ); rep( j, C+1 ) dp[0][j] = 0; rep( i, N ) rep( k, C+1 ) rep( j, G[i].size() ) if( k+G[i][j].cost <= C ) chmin( dp[G[i][j].to][k+G[i][j].cost], dp[i][k]+G[i][j].tim ); printf( "%d\n", dp[N-1][C]==INF?-1:dp[N-1][C] ); return 0; }