#include int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, M, P; long long Y; std::cin >> N >> M >> P >> Y; std::vector>> G(N); for (;M--;) { int a, b, c; std::cin >> a >> b >> c; a--, b--; G[a].emplace_back(b, c); G[b].emplace_back(a, c); } const long long INF = 1LL << 60; std::priority_queue> pq; std::vector dist(N, INF); pq.emplace(0, 0); while (pq.size()) { auto [c, v] = pq.top(); pq.pop(); c *= -1; if (dist[v] > c) { dist[v] = c; for (auto [v2, d] : G[v]) { pq.emplace(-(c + d), v2); } } } long long ans = 0; for (;P--;) { int D, E; std::cin >> D >> E; D--; ans = std::max(ans, (Y - dist[D]) / E); } std::cout << ans << '\n'; }