def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr +=1 C = int(input[ptr]) ptr +=1 V = int(input[ptr]) ptr +=1 S = list(map(int, input[ptr:ptr+V])) ptr +=V T = list(map(int, input[ptr:ptr+V])) ptr +=V Y = list(map(int, input[ptr:ptr+V])) ptr +=V M = list(map(int, input[ptr:ptr+V])) ptr +=V adj = [[] for _ in range(N+1)] for i in range(V): s = S[i] t = T[i] y = Y[i] m = M[i] adj[s].append( (t, y, m) ) INF = 1 << 60 dp = [ [INF] * (C + 1) for _ in range(N + 1) ] dp[1][0] = 0 for i in range(1, N): # Process towns up to N-1 for c in range(C + 1): if dp[i][c] == INF: continue for (j, y, m) in adj[i]: new_cost = c + y if new_cost > C: continue if dp[j][new_cost] > dp[i][c] + m: dp[j][new_cost] = dp[i][c] + m res = INF for c in range(C + 1): if dp[N][c] < res: res = dp[N][c] print(res if res != INF else -1) if __name__ == "__main__": main()