from collections import defaultdict from heapq import heappop, heappush 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())) G = defaultdict(list) for i in range(v): s, t, y, m = S[i], T[i], Y[i], M[i] s -= 1 t -= 1 G[s].append((t, y, m)) INF = 10**18 DP = [[INF for _ in range(c + 1)] for _ in range(n)] DP[0][0] = 0 H = [(0, 0, 0)] while H: cp, cc, ct = heappop(H) if ct > DP[cp][cc]: continue for np, dc, dt in G[cp]: nc = cc + dc nt = ct + dt if nc > c: continue if nt >= DP[np][nc]: continue DP[np][nc] = nt heappush(H, (np, nc, nt)) ans = min(DP[n - 1]) if ans == INF: ans = -1 print(ans)