from collections import deque N = int(input()) C = int(input()) V = int(input()) Sori = list(map(int,input().split())) Tori = list(map(int,input().split())) Yori = list(map(int,input().split())) Mori = list(map(int,input().split())) dic = {} for i in range(V): s = Sori[i]-1 t = Tori[i]-1 y = Yori[i] m = Mori[i] if s not in dic: dic[s] = [] dic[s].append([t,y,m]) lis = [[float("inf")] * (C+1) for i in range(N) ] lis[0][0] = 0 q = deque([]) q.append([0,0]) while len(q) > 0: now = q.popleft() np = now[0] nc = now[1] if np not in dic: continue for i in dic[np]: nexp = i[0] nexc = i[1] dis = i[2] if nc + nexc <= C: if lis[nexp][nc+nexc] > lis[np][nc] + dis: lis[nexp][nc+nexc] = lis[np][nc] + dis q.append([nexp,nc+nexc]) ans = float("inf") #print (lis[-1]) for i in range(C+1): ans = min(ans , lis[-1][i]) if ans == float("inf"): print (-1) else: print (ans)