#include using namespace std; using ll = long long; template using pqg = priority_queue, greater>; int main(){ int N, M, P; ll Y; cin >> N >> M >> P >> Y; vector>> G(N); for (int i = 0; i < M; i++){ int u, v, w; cin >> u >> v >> w; u--, v--; G[u].emplace_back(v, w); G[v].emplace_back(u, w); } vector D(P); vector E(P); for (int i = 0; i < P; i++) cin >> D[i] >> E[i], D[i]--; vector cost(N, LLONG_MAX); pqg> pq; pq.emplace(0, 0); cost[0] = 0; while (!pq.empty()){ auto [d, p] = pq.top(); pq.pop(); if (cost[p] < d) continue; for (auto [u, v] : G[p]){ if (cost[u] > cost[p]+v){ cost[u] = cost[p]+v; pq.emplace(cost[u], u); } } } ll ans = LLONG_MIN; for (int i = 0; i < P; i++){ if (cost[D[i]] > Y) continue; ans = max(ans, (Y-cost[D[i]])/E[i]); } cout << ans << endl;; }