import heapq import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N = int(input()) C = int(input()) V = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) Y = list(map(int, input().split())) M = list(map(int, input().split())) edge = [[] for _ in range(N)] for s, t, y, m in zip(S, T, Y, M): edge[s-1].append((t-1, y, m)) inf = 10**18 dist = [[inf] * (C + 1) for _ in range(N)] dist[0][0] = 0 que = [(0, 0, 0)] # time, cost, pos while que: ds, cs, s = heapq.heappop(que) if dist[s][cs] < ds: continue for t, ct, dt in edge[s]: if ct + cs > C: continue if dist[t][ct + cs] > ds + dt: dist[t][ct + cs] = ds + dt heapq.heappush(que, (ds + dt, ct + cs, t)) ans = inf for i in range(C + 1): ans = min(ans, dist[N-1][i]) if ans >= inf: ans = -1 print(ans)