#include <bits/stdc++.h> using namespace std; using ll = int64_t; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, M, P; ll Y; cin >> N >> M >> P >> Y; vector<vector<pair<int, int>>> adj(N); for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; a--, b--; adj[a].push_back({b, c}); adj[b].push_back({a, c}); } priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> pq; pq.push({0, 0}); vector<ll> dist(N, 1e18); dist[0] = 0; while(!pq.empty()) { auto [d, v] = pq.top(); pq.pop(); if(dist[v] != d) continue; for(const auto&[to, cst]: adj[v]) { if(dist[to] > dist[v] + cst) { dist[to] = dist[v] + cst; pq.push({dist[to], to}); } } } ll ans = 0; while(P--) { int d, e; cin >> d >> e; d--; ll cur = Y - dist[d]; cur /= e; ans = max(ans, cur); } cout << ans << '\n'; }