# https://yukicoder.me/problems/no/3712 from collections import deque import heapq MAX_INT = 2 ** 65 def main(): N, M = map(int, input().split()) next_nodes = [[] for _ in range(N)] for _ in range(M): u, v, w = map(int ,input().split()) next_nodes[u - 1].append((v -1 , w)) next_nodes[v - 1].append((u - 1, w)) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) fix = [MAX_INT] * N seen = [MAX_INT] * N queue = [] heapq.heappush(queue, (0, 0)) seen[0] = 0 while len(queue) >0: cost, v = heapq.heappop(queue) if fix[v] < MAX_INT: continue fix[v] = cost for u, w in next_nodes[v]: if fix[u] < MAX_INT: continue # コスト計算 d = cost % A[v] if d > 0 or cost == 0: next_time = ((cost // A[v]) + 1) * A[v] else: next_time = cost next_time_list = [next_time] if next_time % (A[v] * B[v]) == 0: next_time_list.append(next_time + A[v]) for n in next_time_list: if n % (A[v] * B[v]) == 0: new_cost = n + w + C[v] else: new_cost = n + w if seen[u] > new_cost: seen[u] = new_cost heapq.heappush(queue, (new_cost, u)) print(fix[-1]) if __name__ == "__main__": main()