# coding: utf-8 import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time sys.setrecursionlimit(10 ** 7) INF = 10 ** 20 MOD = 10 ** 9 + 7 def II(): return int(input()) def ILI(): return list(map(int, input().split())) def IAI(LINE): return [ILI() for __ in range(LINE)] def IDI(): return {key: value for key, value in ILI()} def solve(N, C, V, S, T, Y, M): graph = [[] for __ in range(N + 1)] for s, t, y, m in zip(S, T, Y, M): graph[s].append((t, y, m)) dp = collections.defaultdict(lambda: INF) dp[(1, C)] = 0 city_queue = collections.deque([(1, C)]) while city_queue: city_money = city_queue.pop() l_next = graph[city_money[0]] if len(l_next) == 0: continue for next in l_next: now_time = dp[(city_money)] next_time = now_time + next[2] next_money = city_money[1] - next[1] next_city = next[0] if next_money < 0: continue dp[(next_city, next_money)] = min(next_time, dp[(next_city, next_money)]) collections.deque.append(city_queue, (next_city, next_money)) ans = INF for i in range(C + 1): ans = min(ans, dp[(N, i)]) if ans == INF: ans = -1 return ans def main(): N = II() C = II() V = II() S = [0] + ILI() T = [0] + ILI() Y = [0] + ILI() M = [0] + ILI() print(solve(N, C, V, S, T, Y, M)) if __name__ == "__main__": main()