#include #include using namespace std; using namespace atcoder; #define rep(i, n) for(int i=0;i<(n);++i) #define rep1(i, n) for(int i=1;i<=(n);i++) #define ll long long using mint = modint998244353; using P = pair; using lb = long double; using T = tuple; #ifdef LOCAL # include # define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__) #else # define dbg(...) (static_cast(0)) #endif int main() { int n, m, l, s, e; cin >> n >> m >> l >> s >> e; vector> g(n); rep(i,m) { int a, b, t; cin >> a >> b >> t; --a;--b; g[a].emplace_back(b, t); g[b].emplace_back(a, t); } vector t(l); rep(i,l) cin >> t[i]; rep(i,l) --t[i]; const ll INF = 1e18; vector dist(n, INF), rdist(n, INF); dist[0] = 0; rdist[n-1] = 0; priority_queue, greater

> pq; pq.emplace(0, 0); while(!pq.empty()) { auto [d, u] = pq.top();pq.pop(); if(dist[u]!=d) continue; for(auto [v, c] : g[u]) { if(dist[v]>dist[u] + c) { dist[v] = dist[u] + c; pq.emplace(dist[v], v); } } } pq.emplace(0, n-1); while(!pq.empty()) { auto [d, u] = pq.top();pq.pop(); if(rdist[u]!=d) continue; for(auto [v, c] : g[u]) { if(rdist[v]>rdist[u] + c) { rdist[v] = rdist[u] + c; pq.emplace(rdist[v], v); } } } ll ans = INF; dbg(dist, rdist); rep(i,l) { if(dist[t[i]]<=s+e) { ans = min(ans, max((ll)s, dist[t[i]])+1+rdist[t[i]]); } } if(ans==INF) ans = -1; cout << ans << endl; return 0; }