import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; import java.util.List; import java.util.Scanner; public class Main_yukicoder1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int c = sc.nextInt(); int v = sc.nextInt(); int[] s = new int[v]; int[] t = new int[v]; int[] y = new int[v]; int[] m = new int[v]; for (int i = 0; i < v; i++) { s[i] = sc.nextInt(); } for (int i = 0; i < v; i++) { t[i] = sc.nextInt(); } for (int i = 0; i < v; i++) { y[i] = sc.nextInt(); } for (int i = 0; i < v; i++) { m[i] = sc.nextInt(); } List> edges = new ArrayList>(); for (int i = 0; i < n; i++) { edges.add(new ArrayList()); } for (int i = 0; i < v; i++) { edges.get(s[i] - 1).add(new Triple(t[i] - 1, y[i], m[i])); } Deque st = new ArrayDeque(); Deque cst = new ArrayDeque(); Deque mst = new ArrayDeque(); st.push(0); cst.push(0); mst.push(0); int min = Integer.MAX_VALUE; while (!st.isEmpty()) { int e = st.pop(); int ce = cst.pop(); int me = mst.pop(); if (e == n - 1) { min = Math.min(min, me); continue; } for (Triple next : edges.get(e)) { int ne = next.a; int nce = ce + next.b; int nme = me + next.c; if (nce <= c) { st.push(ne); cst.push(nce); mst.push(nme); } } } if (min == Integer.MAX_VALUE) { System.out.println(-1); } else { System.out.println(min); } sc.close(); } private static class Triple { int a; int b; int c; Triple(int a, int b, int c) { this.a = a; this.b = b; this.c = c; } } }