from heapq import * from collections import defaultdict import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def main(): n = II() inf=1000 money = II() m = II() uu = LI1() vv = LI1() cc = LI() tt = LI() to = defaultdict(list) for u, v, c, t in zip(uu, vv, cc, tt): to[u].append([v, c, t]) hp=[] costs=[inf]*n #[時間,都市,コスト] heappush(hp,[0,0,0]) while hp: time,u,cost=heappop(hp) if u==n-1: print(time) exit() if cost>costs[u]:continue costs[u]=cost for v,c,t in to[u]: if cost+c>money:continue heappush(hp,[time+t,v,cost+c]) print(-1) main()