from heapq import heappop, heappush INF = float("inf") def dijkstra(start: int, graph: list[list[tuple[int, int]]]): n = len(graph) pq = [(0, start)] dist = [INF] * n dist[start] = 0 while pq: d, curr = heappop(pq) if d > dist[curr]: continue for to, cost in graph[curr]: nd = dist[curr] + cost if dist[to] <= nd: continue heappush(pq, (nd, to)) dist[to] = nd return dist N, R, C = [int(s) for s in input().split()] X = [int(s) for s in input().split()] Y = [int(s) for s in input().split()] Z = [int(s) for s in input().split()] S = [int(s) for s in input().split()] graph = [[] for _ in range(6 * N + 6)] wk, at, mt, sp = 0, N, 2 * N, 3 * N for i in range(N): # オートマ免許 graph[i + wk].append((i + at, X[i])) graph[i + wk + sp].append((i + at + sp, X[i])) # マニュアル免許 graph[i + wk].append((i + mt, Y[i])) graph[i + at].append((i + mt, Y[i])) graph[i + wk + sp].append((i + mt + sp, Y[i])) graph[i + at + sp].append((i + mt + sp, Y[i])) # 船舶免許 graph[i + wk].append((i + wk + sp, Z[i])) graph[i + at].append((i + at + sp, Z[i])) graph[i + mt].append((i + mt + sp, Z[i])) for _ in range(R): U, V, W, A, M = [int(s) for s in input().split()] U -= 1 V -= 1 # 徒歩 for walk in (wk, at, mt, wk + sp, at + sp, mt + sp): graph[U + walk].append((V + walk, W)) graph[V + walk].append((U + walk, W)) # オートマ車 for auto in (at, mt, at + sp, mt + sp): graph[U + auto].append((V + auto, A)) graph[V + auto].append((U + auto, A)) # マニュアル車 for manu in (mt, mt + sp): graph[U + manu].append((V + manu, M)) graph[V + manu].append((U + manu, M)) # 船舶 for i in range(N): for idx, ship in enumerate((wk + sp, at + sp, mt + sp)): super_u, super_v = 6 * N + 2 * idx, 6 * N + 2 * idx + 1 graph[i + ship].append((super_u, S[i])) graph[super_v].append((i + ship, S[i])) for idx in range(3): super_u, super_v = 6 * N + 2 * idx, 6 * N + 2 * idx + 1 graph[super_u].append((super_v, C)) dist = dijkstra(0, graph) ans = min(dist[N - 1 + N * i] for i in range(6)) print(ans)