import sys from heapq import heappush, heappop def main(): input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]); ptr +=1 M = int(input[ptr]); ptr +=1 K = int(input[ptr]); ptr +=1 R = list(map(int, input[ptr:ptr+K])) ptr += K required_edges = { r: i for i, r in enumerate(R) } adj = [[] for _ in range(N+1)] for edge_idx in range(1, M+1): A = int(input[ptr]); ptr +=1 B = int(input[ptr]); ptr +=1 C = int(input[ptr]); ptr +=1 adj[A].append( (B, C, edge_idx) ) adj[B].append( (A, C, edge_idx) ) INF = float('inf') full_mask = (1 << K) - 1 dist = [ [INF]*(1< dist[u][mask]: continue for (v, c, edge_idx) in adj[u]: new_mask = mask if edge_idx in required_edges: bit = required_edges[edge_idx] new_mask |= (1 << bit) new_cost = cost + c if new_cost < dist[v][new_mask]: dist[v][new_mask] = new_cost heappush(heap, (new_cost, v, new_mask)) print(-1) if __name__ == "__main__": main()