#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define LL long long #define V 50 #define E 1500 #define M 301 LL dp[V][M]; const LL INF = 1e9; LL from[E], to[E], tim[E], cost[E]; LL v, m, e; void solve(){ for (int i = 0; i < V; i++) for (int j = 0; j < M; j++)dp[i][j] = INF; dp[0][0] = 0; for (int i = 0; i < 51; i++){ for (int j = 0; j < e; j++){ for (LL k = cost[j]; k <= m; k++) dp[to[i]][k] = min(dp[to[i]][k], dp[from[i]][k - cost[i]] + tim[i]); } } } int main(void){ cin >> v >> m >> e; v--; for (int i = 0; i < e; i++){ cin >> from[i]; from[i]--; } for (int i = 0; i < e; i++){ cin >> to[i]; to[i]--; } for (int i = 0; i < e; i++)cin >> cost[i]; for (int i = 0; i < e; i++)cin >> tim[i]; solve(); LL res = INF; for (int i = 0; i <= m; i++) res = min(res, dp[v][i]); cout << ((res==INF)?-1:res) << endl; return 0; }