mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline import heapq def dijkstra(adj, start, idx, K): # adj: [[to, cost] * vertices], 0th index must be empty inf = 1 << 60 N = len(adj) - 1 dist = [inf] * (1 + N * (1 << K)) dist[start] = 0 q = [] heapq.heappush(q, (0, start)) while q: min_dist, v_from = heapq.heappop(q) if min_dist > dist[v_from]: continue vf = ((v_from - 1) % N) + 1 state = (v_from - 1) // N v_tos = adj[vf] for v_to, cost in v_tos: ab = vf * mod + v_to if ab in idx: j = idx[ab] state_new = state | (1 << j) else: state_new = state v_to_ = v_to + N * state_new if min_dist + cost < dist[v_to_]: dist[v_to_] = min_dist + cost heapq.heappush(q, (dist[v_to_], v_to_)) return dist N, M, K = map(int, input().split()) R = list(map(int, input().split())) idx = {r: i for i, r in enumerate(R)} adj = [[] for _ in range(N + 1)] idx_ab = {} for i in range(1, M+1): a, b, c = map(int, input().split()) adj[a].append((b, c)) adj[b].append((a, c)) if i in idx: j = idx[i] idx_ab[a * mod + b] = j idx_ab[b * mod + a] = j dist = dijkstra(adj, 1, idx_ab, K) print(dist[-1]) if __name__ == '__main__': main()