from typing import List, Tuple, Optional import sys import itertools import heapq import bisect from collections import deque, defaultdict from functools import lru_cache, cmp_to_key input = sys.stdin.readline # for AtCoder Easy test if __file__ != 'prog.py': # sys.setrecursionlimit(10 ** 6) pass def readints(): return map(int, input().split()) def readlist(): return list(readints()) def readstr(): return input().rstrip() class Dijkstra: def __init__(self, N: int, E: List[List[Tuple[int, int]]], start: int = 0, inf: int = 1 << 50): self.N = N self.E = E self.start = start self.inf = inf self.C = [self.inf] * N # self.prev = [None] * N self._calculate() def get_cost(self, i: int) -> Optional[int]: """return cost to i-th vertex if reachable otherwise None""" return self.C[i] if self.reachable(i) else self.inf def get_path(self, i) -> Optional[List[int]]: """return shortest path to i-th vertex if reachable otherwise None""" if not self.reachable(i): return None p = [] cur = i while cur is not None: p.append(cur) cur = self.prev[cur] p.reverse() return p def reachable(self, i) -> bool: """return whether i-th vertex from start is reachable""" return self.C[i] < self.inf def _calculate(self) -> None: h = [(0, self.start)] self.C[self.start] = 0 visited = [False] * self.N while h: _, v = heapq.heappop(h) if visited[v] is True: continue visited[v] = True for c, d in self.E[v]: if self.C[d] > self.C[v] + c: self.C[d] = self.C[v] + c # self.prev[d] = v heapq.heappush(h, (self.C[d], d)) N = int(input()) C = int(input()) V = int(input()) S = list(map(lambda x: int(x) - 1, input().split())) T = list(map(lambda x: int(x) - 1, input().split())) Y = readlist() M = readlist() E = [[] for _ in range(N * (C + 1))] for i in range(V): for j in range(C, 0, -1): def h(v, c): return v * (C + 1) + c if j - Y[i] < 0: break E[h(S[i], j)].append((M[i], h(T[i], j - Y[i]))) solver = Dijkstra(N * (C + 1), E, start=C) ans = solver.inf for j in range(C + 1): ans = min(ans, solver.get_cost((N - 1) * (C + 1) + j)) print(ans if ans < solver.inf else -1)