mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline import heapq def dijkstra(adj, start): # adj: [[to, cost] * vertices], 0th index must be empty inf = 1 << 60 dist = [inf] * len(adj) 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 v_tos = adj[v_from] for v_to, cost in v_tos: 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 << K) + 1)] for i in range(1, M+1): a, b, c = map(int, input().split()) if i not in idx: for state in range(1 << K): aa = a + state * N bb = b + state * N adj[aa].append((bb, c)) adj[bb].append((aa, c)) else: j = idx[i] for state in range(1 << K): aa = a + state * N bb = b + state * N state_new = state | (1 << j) aaa = a + state_new * N bbb = b + state_new * N adj[aa].append((bbb, c)) adj[bb].append((aaa, c)) dist = dijkstra(adj, 1) print(dist[-1]) if __name__ == '__main__': main()