#include using namespace std; bool chmin(int &x,int y) { if(x > y) { x = y; return true; } return false; } int main() { int N,M,K; cin >> N >> M >> K; vectorR(K); for(int i = 0; i < K; i++) { cin >> R[i]; R[i]--; } vector>>road(N); for(int i = 0; i < M; i++) { int A,B,C; cin >> A >> B >> C; A--; B--; int id = -1; for(int j = 0; j < K; j++) { if(R[j] == i) { id = j; } } road[A].push_back({B,C,id}); road[B].push_back({A,C,id}); } vector>dist(N,vector(1 << K,1001001001)); priority_queue,vector>,greater>>que; dist[0][0] = 0; que.push({0,0,0}); while (!que.empty()) { auto x = que.top(); que.pop(); if(dist[x[1]][x[2]] != x[0]) { continue; } for(auto i:road[x[1]]) { int to1 = i[0]; int to2 = x[2]; if(i[2] != -1) { to2 |= (1 << i[2]); } if(chmin(dist[to1][to2],i[1]+x[0])) { que.push({i[1]+x[0],to1,to2}); } } } cout << dist[N-1][(1 << K)-1] << endl; }