import sys import heapq sys.setrecursionlimit(10 ** 6) # ===== 入出力ヘルパ ===== def input() -> str: return sys.stdin.readline().rstrip() def INT() -> int: return int(input()) def MAP(): return map(int, input().split()) def LIST() -> list[int]: return list(MAP()) # ===== 定数 ===== INF = 10 ** 18 # ===== 関数短縮 ===== hpu = heapq.heappush hpo = heapq.heappop # ============================================== # =================== main ===================== # ============================================== def main() -> None: N, M = MAP() edges = dict(zip(range(N), [[] for _ in range(N)])) for _ in range(M): u, v, t = MAP() edges[u-1].append((v-1, t)) edges[v-1].append((u-1, t)) A = LIST() B = LIST() C = LIST() h = [] hpu(h, (1, 0)) while h: c, u = hpo(h) if u == N-1: print(c) return c = (c+A[u]-1) // A[u] k = c c *= A[u] for v, t in edges[u]: if k % B[u] == 0: if C[u] < A[u]: hpu(h, (c+t+C[u], v)) else: hpu(h, (c+t+A[u], v)) else: hpu(h, (c+t, v)) if __name__ == "__main__": main()