import heapq def main(): n = int(input()) c = int(input()) v_num = int(input()) s_list = list(map(int, input().split())) t_list = list(map(int, input().split())) y_list = list(map(int, input().split())) m_list = list(map(int, input().split())) adj = [[] for _ in range(n + 1)] for i in range(v_num): s = s_list[i] t = t_list[i] y = y_list[i] m = m_list[i] adj[s].append((t, y, m)) INF = float('inf') dp = [[INF] * (c + 1) for _ in range(n + 1)] dp[1][0] = 0 heap = [] heapq.heappush(heap, (0, 1, 0)) while heap: current_time, u, current_cost = heapq.heappop(heap) if current_time > dp[u][current_cost]: continue for edge in adj[u]: v, y, m = edge new_cost = current_cost + y if new_cost > c: continue new_time = current_time + m if new_time < dp[v][new_cost]: dp[v][new_cost] = new_time heapq.heappush(heap, (new_time, v, new_cost)) min_time = INF for cost in range(c + 1): if dp[n][cost] < min_time: min_time = dp[n][cost] print(-1 if min_time == INF else min_time) if __name__ == "__main__": main()