#include using namespace std; const long long inf = 1LL << 60; struct G{ int npos; long long c; int dbit; }; struct HQ{ long long d; int pos; int bit; bool operator<(const HQ& right) const{ return d > right.d; } }; int main(void){ int n, m, k; cin >> n >> m >> k; map R; int r; for(int i = 0; i < k; i++){ cin >> r; R[r - 1] = 1 << i; } vector> edges(n, vector()); int a, b, c, d; for(int i = 0; i < m; i++){ cin >> a >> b >> c; a--; b--; edges[a].push_back({b, c, R[i]}); edges[b].push_back({a, c, R[i]}); } vector> dist(n, vector(1 << k, inf)); dist[0][0] = 0; priority_queue hq; hq.push({0, 0, 0}); while(!hq.empty()){ auto a = hq.top(); hq.pop(); if(a.d > dist[a.pos][a.bit]) continue; for(auto b: edges[a.pos]){ int nbit = a.bit | b.dbit; if(dist[b.npos][nbit] > b.c + a.d){ dist[b.npos][nbit] = b.c + a.d; hq.push({b.c + a.d, b.npos, nbit}); } } } cout << dist[n - 1][(1 << k) - 1] << "\n"; }