#include #include #include using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; //using mint = modint1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repu(i, s, t) for (int i = (int)(s); i < (int)(t); i++) #define repd(i, s, t) for (int i = (int)(s)-1; i >= (int)(t); i--) #define all(v) v.begin(), v.end() template bool chmax(T &a, const T b) { if(a >= b) return false; a = b; return true; } template bool chmin(T &a, const T b) { if(a <= b) return false; a = b; return true; } template istream& operator>>(istream &in, vector &a) { for(T &x: a) in >> x; return in; } template ostream& operator<<(ostream &out, const vector &a) { for(const T &x: a) out << x << ' '; return out; } const int di[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dj[] = {0, 1, 0, -1, -1, 1, 1, -1, 0}; 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 ts(l); cin >> ts; rep(i, l) ts[i]--; using P = pair; priority_queue, greater

> pq; auto dij = [&](vector &dist) { while(!pq.empty()) { auto [d, pos] = pq.top(); pq.pop(); if(dist[pos] < d) continue; for(auto[to, c]: g[pos]) { if(chmin(dist[to], dist[pos] + c)) { pq.emplace(dist[to], to); } } } }; const ll INF = 1e18; vector d1(n, INF); d1[0] = 0; pq.emplace(0, 0); dij(d1); vector d2(n, INF); for(int x: ts) { if(d1[x] >= s+e) continue; d2[x] = max(ll(s), d1[x]) + 1; pq.emplace(d2[x], x); } dij(d2); cout << (d2[n-1] < INF ? d2[n-1] : -1) << endl; return 0; }