import java.io.*; import java.util.*; class Main1 { static int n , c; static int ans = -1; static int[][][] memo; public static void out (Object o) { System.out.println(o); } public static void solve (int nowPoint , int cost , int time) { for (int i = nowPoint + 1; i <= n; i++) { if (memo[nowPoint][i][0] == 0) continue; if (cost + memo[nowPoint][i][0] > c) continue; if (i != n) { solve(i , cost + memo[nowPoint][i][0] , time + memo[nowPoint][i][1]); } else { ans = ans == -1 ? time + memo[nowPoint][i][1] : Math.min(ans , time + memo[nowPoint][i][1]); } } } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(br.readLine()); c = Integer.parseInt(br.readLine()); int v = Integer.parseInt(br.readLine()); String[] line1 = br.readLine().split(" "); String[] line2 = br.readLine().split(" "); String[] line3 = br.readLine().split(" "); String[] line4 = br.readLine().split(" "); memo = new int[n + 1][n + 1][2]; for (int i = 0; i < v; i++) { int s = Integer.parseInt(line1[i]); int t = Integer.parseInt(line2[i]); int y = Integer.parseInt(line3[i]); int m = Integer.parseInt(line4[i]); memo[s][t][0] = y; memo[s][t][1] = m; } solve(1,0,0); out(ans); } }