#include using namespace std; const int INF = 0x3f3f3f3f; signed main(){ int N, C, V; cin >> N >> C >> V; vector< int > S( V ), T( V ), Y( V ), M( V ); for( int i = 0; i < V; ++i ) cin >> S[ i ], --S[ i ]; for( int i = 0; i < V; ++i ) cin >> T[ i ], --T[ i ]; for( int i = 0; i < V; ++i ) cin >> Y[ i ]; for( int i = 0; i < V; ++i ) cin >> M[ i ]; priority_queue< tuple< int, int, int >, vector< tuple< int, int, int > >, greater< tuple< int, int, int > > > pq; vector< vector< int > > dp( N, vector< int >( C + 1, INF ) ); pq.emplace( dp[ 0 ][ C ] = 0, 0, C ); while( not pq.empty() ){ int d, u, c; tie( d, u, c ) = pq.top(); pq.pop(); if( u == N - 1 ) cout << d << endl, exit( 0 ); if( d != dp[ u ][ c ] ) continue; for( int i = 0; i < V; ++i ) if( u == S[ i ] and c >= Y[ i ] ) if( dp[ T[ i ] ][ c - Y[ i ] ] > dp[ u ][ c ] + M[ i ] ) dp[ T[ i ] ][ c - Y[ i ] ] = dp[ u ][ c ] + M[ i ], pq.emplace( dp[ T[ i ] ][ c - Y[ i ] ], T[ i ], c - Y[ i ] ); } cout << -1 << endl; return 0; }