#!/usr/bin/env python3 def memoize(fn): table = {} def func(*args): if args not in table: table[args] = fn(*args) return table[args] return func class Town(object): def __init__(self, num): self.edge_forward = [] self.edge_backward = [] self.num = num self.is_start = False self.is_goal = False def append_forward(self, edge): self.edge_forward.append(edge) def append_backward(self, edge): self.edge_backward.append(edge) class Edge(object): def __init__(self, frm, to, cost, distance): self.frm = frm self.to = to self.cost = cost self.distance = distance @memoize def path(town): if town.is_start: return [(0, 0)] p = [] for e in town.edge_backward: for cost, distance in path(e.frm): cost += e.cost distance += e.distance p.append((cost, distance)) return p N = int(input()) C = int(input()) V = int(input()) S = [int(s) for s in input().split()] T = [int(t) for t in input().split()] Y = [int(y) for y in input().split()] M = [int(m) for m in input().split()] town = [Town(num) for num in range(N)] RODE = zip(S, T, Y, M) for s, t, y, m in RODE: town[s - 1].append_forward(Edge(town[s - 1], town[t - 1], y, m)) town[t - 1].append_backward(Edge(town[s - 1], town[t - 1], y, m)) town[0].is_start = True town[-1].is_goal = True ways = path(town[-1]) p = [d for c, d in ways if c <= C] if len(p) == 0: print(-1) else: print(min(p))