n = int(input()) c = int(input()) v = 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())) edges = [[] for _ in range(n + 1)] for s, t, y, m in zip(s_list, t_list, y_list, m_list): edges[s].append((t, y, m)) INF = float('inf') dp = [[INF] * (c + 1) for _ in range(n + 1)] dp[1][0] = 0 # Starting at town 1 with 0 cost and 0 time for current_town in range(1, n + 1): for current_cost in range(c + 1): if dp[current_town][current_cost] == INF: continue for (next_town, road_cost, time) in edges[current_town]: new_cost = current_cost + road_cost if new_cost > c: continue if dp[next_town][new_cost] > dp[current_town][current_cost] + time: dp[next_town][new_cost] = dp[current_town][current_cost] + time min_time = min(dp[n][:c + 1]) print(-1 if min_time == INF else min_time)