#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int INF = 10000000; vector > wy, wm; vector ry, rm; int n, c, v; void dfs(int x, int y, int m) { if(y > c || m > rm[x]) { return; } ry[x] = y; rm[x] = m; for(int i = 0; i < n; i++) { if(wy[x][i] != -1) { dfs(i, y + wy[x][i], m + wm[x][i]); } } } int main() { cin >> n >> c >> v; wy = wm = vector >(n, vector(n, -1)); ry = rm = vector(n, INF); vector ss(v), ts(v), ys(v), ms(v); for(int i = 0; i < v; i++) { cin >> ss[i]; } for(int i = 0; i < v; i++) { cin >> ts[i]; } for(int i = 0; i < v; i++) { cin >> ys[i]; } for(int i = 0; i < v; i++) { cin >> ms[i]; } for(int i = 0; i < v; i++) { wy[ss[i]-1][ts[i]-1] = wy[ts[i]-1][ss[i]-1] = ys[i]; wm[ss[i]-1][ts[i]-1] = wm[ts[i]-1][ss[i]-1] = ms[i]; } dfs(0, 0, 0); if(rm[n-1] == INF) { cout << -1 << endl; } else { cout << rm[n-1] << endl; } return 0; }