#include using namespace std; #ifndef ONLINE_JUDGE #include "algo/debug.h" #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif #define int long long const int INF = 1e15; void solve() { int n, m, l, s, e; cin >> n >> m >> l >> s >> e; vector>> g(n); for (int i = 0, a, b, w; i < m; i++) { cin >> a >> b >> w; a--, b--; g[a].push_back({b, w}); g[b].push_back({a, w}); } vector spec(l); for (auto &x : spec) { cin >> x; x--; } e = s + e; vector> min_dist(2, vector(n, INF)); // Lambda function for Dijkstra's algorithm auto dijkstra = [&](int start, int id) { priority_queue, vector>, greater>> pq; min_dist[id][start] = 0; pq.push({0, start}); // {distance, node} while (!pq.empty()) { auto [d, u] = pq.top(); pq.pop(); if (d > min_dist[id][u]) continue; // Skip if we have already found a better path for (auto [v, weight] : g[u]) { if (min_dist[id][u] + weight < min_dist[id][v]) { min_dist[id][v] = min_dist[id][u] + weight; pq.push({min_dist[id][v], v}); } } } }; dijkstra(0, 0); dijkstra(n - 1, 1); int ans = INF; for (auto &x : spec) { if (min_dist[0][x] < e) { ans = min(ans, max(s, min_dist[0][x]) + 1 + min_dist[1][x]); } } cout << (ans == INF ? -1 : ans) << '\n'; } signed main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else #endif ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { solve(); } // cerr << "Time elapsed: " << ((long double)clock() / CLOCKS_PER_SEC) << " s.\n"; }