#include #include #include using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 int main(){ int N,M,T; cin>>N>>M>>T; vector dis(N,vector(N,Inf)); rep(i,M){ int a,b,c; cin>>a>>b>>c; a--;b--; dis[a][b] = c; dis[b][a] = c; } rep(i,N)dis[i][i] = 0; rep(i,N){ rep(j,N){ rep(k,N){ dis[j][k] = min(dis[j][k], dis[j][i]+dis[i][k]); } } } vector v(T); rep(i,T){ cin>>v[i]; v[i]--; } sort(v.begin(),v.end()); vector cov; rep(i,N){ if(!binary_search(v.begin(),v.end(),i))cov.push_back(i); } int ans = Inf; if(T<=15){ vector dp(N,vector(1<>> E; rep(j,N){ for(int k=j+1;k f(N,false); rep(i,v.size())f[v[i]] = true; rep(i,1<>j)&1)f[cov[j]] = true; } dsu D(N); int temp = 0; rep(j,E.size()){ int x = E[j].second.first,y = E[j].second.second; if(f[x]&&f[y]){ if(!D.same(x,y)){ D.merge(x,y); temp += E[j].first; } } } ans = min(ans,temp); rep(j,cov.size()){ if((i>>j)&1)f[cov[j]] = false; } } } cout<