#include #ifdef LOCAL #include #else #define debug(...) void(0) #endif using namespace std; typedef long long ll; #define all(x) begin(x), end(x) constexpr int INF = (1 << 30) - 1; constexpr long long IINF = (1LL << 60) - 1; constexpr int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; template istream& operator>>(istream& is, vector& v) { for (auto& x : v) is >> x; return is; } template ostream& operator<<(ostream& os, const vector& v) { auto sep = ""; for (const auto& x : v) os << exchange(sep, " ") << x; return os; } template bool chmin(T& x, U&& y) { return y < x and (x = forward(y), true); } template bool chmax(T& x, U&& y) { return x < y and (x = forward(y), true); } template void mkuni(vector& v) { sort(begin(v), end(v)); v.erase(unique(begin(v), end(v)), end(v)); } template int lwb(const vector& v, const T& x) { return lower_bound(begin(v), end(v), x) - begin(v); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, K, M, P; cin >> N >> K >> M >> P; vector> G(N); for (; M--;) { int u, v; cin >> u >> v; u--, v--; G[u].emplace_back(v); G[v].emplace_back(u); } vector s(N); cin >> s; vector x(K); for (int& val : x) cin >> val, val--; vector quarantine(N, false), immune(N, false); vector cnt(N, 0); /* 0 : 回復 1 : 感染 */ priority_queue, vector>, greater>> pq; // (時刻、イベント、対象者、感染源) for (int& val : x) pq.emplace(0, 1, val, -1); while (not pq.empty()) { auto [time, event, idx, from] = pq.top(); pq.pop(); if (quarantine[idx]) continue; if (event == 0) { immune[idx] = true; } else { if (immune[idx]) continue; if (from != -1 and quarantine[from]) continue; if (++cnt[idx] == 2) { quarantine[idx] = true; continue; } pq.emplace(time + P, 0, idx, -1); for (int& adj : G[idx]) pq.emplace(time + s[idx], 1, adj, idx); } } int ans = 0; for (int i = 0; i < N; i++) { if (quarantine[i]) { ans++; } } cout << ans << '\n'; return 0; }