import sys import pypyjit import itertools import heapq import math from collections import deque, defaultdict import bisect input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) pypyjit.set_param('max_unroll_recursion=-1') N = int(input()) C = int(input()) V = int(input()) S = list(map(int, input().split())) T = list(map(int, input().split())) Y = list(map(int, input().split())) M = list(map(int, input().split())) INF = 1 << 30 E = [[] for _ in range(N + 1)] for s, t, y, m in zip(S, T, Y, M): E[s].append((t, y, m)) # dp[i][j] := 町iに総コストjかけて辿り着ける最小の時間 dp = [[INF for _ in range(C + 1)] for _ in range(N + 1)] dp[1][0] = 0 h = [(0, 1, 0)] while len(h) > 0: _, v, c = heapq.heappop(h) for d, y, m in E[v]: if c + y > C: continue if dp[d][c + y] > dp[v][c] + m: dp[d][c + y] = dp[v][c] + m heapq.heappush(h, (dp[d][c + y], d, c + y)) ans = min(dp[N]) print(ans if ans < INF else -1)