#include using namespace std; #define rep(i, n) for(int i = 0; i < n; i++ ) using ll = long long; int main() { int N, M, p; ll Y; cin >> N >> M >> p >> Y; using P = pair; vector> g(N); rep(i, M) { int a, b, c; cin >> a >> b >> c; a--; b--; g[a].push_back(P(c, b)); g[b].push_back(P(c, a)); } vector s(N); rep(i, p) { int d, e; cin >> d >> e; d--; s[d] = e; } ll INF = 2e18; vector cost(N, INF); cost[0] = 0; priority_queue, greater

> q; q.push(P(0, 0)); while(q.size()) { ll c; int u; tie(c, u) = q.top(); q.pop(); if(c > cost[u]) continue; for(P p : g[u]) { ll co = p.first; int v = p.second; if(cost[v] > c + co) { cost[v] = c + co; q.push(P(cost[v], v)); } } } ll ans = 0; rep(i, N) { if(cost[i] == INF) continue; ll r = max(0LL, Y - cost[i]); if(s[i]) ans = max(ans, r / s[i]); } cout << ans << endl; }