#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(b, c)); g[b].push_back(P(a, c)); } vector s(N), v(N); rep(i, p) { int d, e; cin >> d >> e; d--; s[d] = e; } vector h(N); queue

q; q.push(P(0, Y)); v[0] = 1; if(s[0]) h[0] = Y / s[0]; while(q.size()) { int u; ll y; tie(u, y) = q.front(); q.pop(); for(P p : g[u]) { int t = p.first; if(v[t]) continue; v[t] = 1; ll l = p.second; ll r = max(0LL, y - l); if(s[t]) h[t] = r / s[t]; if(r) q.push(P(t, r)); } } ll ans = 0; rep(i, N) ans = max(ans, h[i]); cout << ans << endl; }