class heap_queue: def __init__(self): self.queue = [(0, 0, 0)] # 時間, 駅, コスト def add(self, *item): self.queue.append(tuple(item)) self.queue.sort(key=lambda x:x[0], reverse=True) def dequeue(self): if not self.size(): return False return self.queue.pop() def size(self): return len(self.queue) N = int(input()) C = int(input()) V = int(input()) S = [[i] for i in map(lambda x:int(x) - 1, input().split())] # 行く前 T = list(map(lambda x:int(x) - 1, input().split())) # 行った後 Y = list(map(int, input().split())) # コスト M = list(map(int, input().split())) # 時間 NUM = [0 for i in range(N + 1)] for i in range(V): S[i] += [T[i], Y[i], M[i]] # 行く前 行った後 コスト 時間 NUM[S[i][0] + 1] += 1 S.sort(key=lambda x:x[0]) for i in range(1, N + 1): NUM[i] += NUM[i - 1] dp = [10 ** 9 for j in range(N)] dp[0] = 0 heap = heap_queue() while heap.size(): data = list(heap.dequeue()) for i in range(NUM[data[1]], NUM[data[1] + 1]): if S[i][2] + data[2] <= C: dp[S[i][1]] = min(dp[S[i][1]], data[0] + S[i][3]) heap.add(dp[S[i][1]], S[i][1], S[i][2] + data[2]) print(dp[N - 1] if dp[N - 1] != 10 ** 9 else -1)