from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline sys.setrecursionlimit(10**6) 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())) INF = (1<<60) dp = [[INF]*(C+2) for _ in range(N)] e = [[] for _ in range(N)] for i in range(V): s,t,y,m = S[i],T[i],Y[i],M[i] s -= 1 t -= 1 e[s].append((t,y,m)) e[t].append((s,y,m)) dp[0][0] = 0 def f(x): return min(x,C+1) for i in range(N-1): for v,y,m in e[i]: for j in range(C+1): dp[v][f(j+y)] = min(dp[v][f(j+y)],dp[i][j]+m) ans = min(dp[-1][:C+1]) if ans==INF: print(-1) else: print(ans)