n = gets.to_i - 1 c = gets.to_i v = gets.to_i s = gets.split.map{|s| s.to_i - 1 } t = gets.split.map{|s| s.to_i - 1 } y = gets.split.map(&:to_i) # コスト m = gets.split.map(&:to_i) # 時間 d = Hash.new do |h1, k1| h1[k1] = Hash.new{|h2, k2| h2[k2] = []} end v.times do |i| d[s[i]][t[i]] = d[t[i]][s[i]] = [y[i], m[i]] end # dp[現在地点][コスト] = 時間 dp = Array.new(n + 1){ Array.new(c + 1, Float::INFINITY) } dp[0][0] = 0 [*0..(n + 1)].product([*0..(c + 1)]) do |current, amount| d[current].each do |nxt, (cost, hour)| if amount + cost <= c dp[nxt][amount + cost] = [dp[nxt][amount + cost], dp[current][amount] + hour].min end end end ans = dp[n].min puts (ans == Float::INFINITY) ? -1 : ans