n = int(input()) c = int(input()) a = 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 i in range(n)] for i in range(a): s, t, y, m = S[i], T[i], Y[i], M[i] s, t = s-1, t-1 edge[s].append((y, m, t)) edge[t].append((y, m, s)) INF = 10**18 import heapq hq = [(0, 0, 0)] heapq.heapify(hq) while hq: time, cost, v = heapq.heappop(hq) if v == n-1: print(time) exit() for y, m, u in edge[v]: if cost+y <= c: heapq.heappush(hq, (time+m, cost+y, u)) print(-1)