#include<bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10,M = 2e4 + 10;
typedef pair<int,int> PII;
priority_queue<PII,vector<PII>,greater<>> heap;
int n,m,s;
int W;
int dist[N];
int h[N],ne[M],e[M],w[M],idx;
bool st[N];
void add(int a,int b,int c)
{
ne[idx] = h[a],e[idx] = b,w[idx] = c,h[a] = idx ++;
}
void dijkstra()
{
while(!heap.empty())
{
auto t = heap.top();
heap.pop();
int y = t.second;
if(st[y]) continue;
st[y] = true;
for(int i = h[y]; ~i; i = ne[i])
{
int j = e[i];
if(dist[j] > dist[y] + w[i])
{
dist[j] = dist[y] + w[i];
heap.emplace(dist[j],j);
}
}
}
}
void solve()
{
memset(st,0,sizeof st);
memset(dist,0x3f,sizeof dist);
memset(h,-1,sizeof h);
idx = 0;
while(m --)
{
int a,b,c;
cin >> a >> b >> c;
add(a,b,c);
}
cin >> W;
while(W --)
{
int a;
cin >> a;
dist[a] = 0;
heap.emplace(0,a);
}
dijkstra();
if(dist[s] >= 0x3f3f3f3f) cout << -1 << endl;
else cout << dist[s] << endl;
}
int main()
{
while(scanf("%d%d%d",&n,&m,&s) != -1) solve();
return 0;
}