#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m; ll p, y; cin >> n >> m >> p >> y; vector>> g(n); for(int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; a--, b--; g[a].emplace_back(b, c); g[b].emplace_back(a, c); } priority_queue, vector>, greater>> pq; vector dp(n, 1ll << 60); dp[0] = 0; pq.emplace(0, 0); while(!pq.empty()){ auto [d, v] = pq.top(); pq.pop(); if(d > dp[v]) continue; for(auto [u, w] : g[v]){ if(d + w >= dp[u]) continue; dp[u] = d + w; pq.emplace(d + w, u); } } ll ans = 0; while(p--){ int v, e; cin >> v >> e; v--; ans = max(ans, (y - dp[v]) / e); } cout << ans << '\n'; }