import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static class State implements Comparable { int node, cost, time; public State(int node, int cost, int time) { super(); this.node = node; this.cost = cost; this.time = time; } public int compareTo(State o) { if(Integer.compare(this.time, o.time) != 0){ return Integer.compare(this.time, o.time); }else if(Integer.compare(this.cost, o.cost) != 0){ return Integer.compare(this.cost, o.cost); }else if(Integer.compare(this.node, o.node) != 0){ return Integer.compare(this.node, o.node); }else{ return 0; } } } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final int C = sc.nextInt(); final int V = sc.nextInt(); int[] S = new int[V]; for(int i = 0; i < V; i++){ S[i] = sc.nextInt() - 1; } int[] T = new int[V]; for(int i = 0; i < V; i++){ T[i] = sc.nextInt() - 1; } int[] Y = new int[V]; for(int i = 0; i < V; i++){ Y[i] = sc.nextInt(); } int[] M = new int[V]; for(int i = 0; i < V; i++){ M[i] = sc.nextInt(); } ArrayList> nexts = new ArrayList>(); ArrayList> costs = new ArrayList>(); ArrayList> times = new ArrayList>(); for(int i = 0; i < N; i++){ nexts.add(new HashSet()); costs.add(new HashMap()); times.add(new HashMap()); } for(int i = 0; i < V; i++){ nexts.get(S[i]).add(T[i]); costs.get(S[i]).put(T[i], Math.min(Y[i], costs.get(S[i]).containsKey(T[i]) ? costs.get(S[i]).get(T[i]) : Integer.MAX_VALUE)); times.get(S[i]).put(T[i], Math.min(M[i], times.get(S[i]).containsKey(T[i]) ? times.get(S[i]).get(T[i]) : Integer.MAX_VALUE)); } boolean[][] visited = new boolean[N][C + 1]; PriorityQueue queue = new PriorityQueue(); queue.add(new State(0, 0, 0)); while(!queue.isEmpty()){ final State state = queue.poll(); if(visited[state.node][state.cost]){ continue; }else{ visited[state.node][state.cost] = true; } if(state.node == N - 1){ System.out.println(state.time); return; } for(final int next : nexts.get(state.node)){ final int next_cost = state.cost + costs.get(state.node).get(next); final int next_time = state.time + times.get(state.node).get(next); if(next_cost > C){ continue; }else if(visited[next][next_cost]){ continue; } queue.add(new State(next, next_cost, next_time)); } } System.out.println(-1); } }