#include typedef long long ll; typedef std::pair P; typedef std::priority_queue, std::greater

> PQ; int main() { long long n, m, p, y; std::cin >> n >> m >> p >> y; std::vector> path(n); std::vector h(n, -1); for (int i = 0; i < m; ++i) { ll a, b, c; std::cin >> a >> b >> c; --a, --b; path[a].push_back({b, c}); path[b].push_back({a, c}); } for (int i = 0; i < p; ++i) { ll d, e; std::cin >> d >> e; --d; h[d] = e; } std::vector dist(n, 1e17); dist[0] = 0; PQ pq; pq.push({0, 0}); while (!pq.empty()) { ll udist = pq.top().first; ll u = pq.top().second; pq.pop(); if (udist > dist[u]) continue; for (auto edge : path[u]) { ll v = edge.first; ll c = edge.second; if (dist[v] > udist + c) { dist[v] = udist + c; pq.push({udist + c, v}); } } } ll ans = 0; for (int i = 0; i < n; ++i) { if (h[i] == -1) continue; if (dist[i] > 1e16) continue; ll r = y - dist[i]; ans = std::max(ans, r / h[i]); } std::cout << ans << std::endl; }