#include <bits/stdc++.h>
using namespace std;
int adj[101][101];
int dp[101][101][258];
bool hascal[101][101][258];
int s[8],ss;
int solve(int x,int y, int mask, int dist)
{
if(hascal[x][y][mask])
{
return dp[x][y][mask];
}
if(mask==0)
{
return dist;
}
else
{
hascal[x][y][mask]=true;
int temp;
int mn=INT_MAX;
for(temp=0;temp<ss;temp++)
{
if(mask & (1<<temp))
{
int target=s[temp];
mn=min(mn,solve(target,y,mask ^ (1<<temp),dist+adj[x][target]));
mn=min(mn,solve(x,target,mask ^ (1<<temp),dist+adj[y][target]));
}
}
dp[x][y][mask]=mn;
return mn;
}
}
int main()
{
int temp,temp2,temp3,INF=10e8;
for(temp=0;temp<=100;temp++)
{
for(temp2=0;temp2<=100;temp2++)
{
if(temp==temp2)
adj[temp][temp2]=0;
else
adj[temp][temp2]=INF;
}
}
int m,n;
scanf("%d %d",&m,&n);
for(temp=0;temp<n;temp++)
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
adj[a][b]=adj[b][a]=min(adj[a][b],c);
}
for(temp3=0;temp3<m;temp3++)
{
for(temp=0;temp<m;temp++)
{
for(temp2=0;temp2<m;temp2++)
{
adj[temp2][temp]=min(adj[temp][temp2],adj[temp][temp3]+adj[temp3][temp2]);
}
}
}
scanf("%d",&ss);
for(temp=0;temp<ss;temp++)
{
scanf("%d",&s[temp]);
}
int x,y;
scanf("%d %d",&x,&y);
int ans=solve(x,y,pow(2,ss)-1,0);
printf("%d\n",ans);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgYWRqWzEwMV1bMTAxXTsKaW50IGRwWzEwMV1bMTAxXVsyNThdOwpib29sIGhhc2NhbFsxMDFdWzEwMV1bMjU4XTsKaW50IHNbOF0sc3M7CgppbnQgc29sdmUoaW50IHgsaW50IHksIGludCBtYXNrLCBpbnQgZGlzdCkKewoJaWYoaGFzY2FsW3hdW3ldW21hc2tdKQoJewoJCXJldHVybiBkc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