#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  ll n, m, p, y;
  cin >> n >> m >> p >> y;
  vector Graph(n, vector<pair<ll, ll>>(0));
  vector<ll> price(n, -1);
  rep(_, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    Graph[a].push_back({ b, c });
    Graph[b].push_back({ a, c });
  }
  rep(_, p) {
    ll d, e;
    cin >> d >> e;
    --d;
    price[d] = e;
  }
  constexpr ll INF = 1e18;
  vector<ll> dist(n, INF);
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
  pq.push({ 0, 0 });
  dist[0] = 0;
  while (!pq.empty()) {
    auto [d, v] = pq.top();
    pq.pop();
    if (dist[v] < d) continue;
    for (auto [u, c] : Graph[v]) {
      if (dist[u] > d + c) {
        dist[u] = d + c;
        pq.push({ dist[u], u });
      }
    }
  }
  ll ans = 0;
  rep(i, n) {
    if (price[i] == -1) continue;
    ans = max(ans, (y - dist[i]) / price[i]);
  }
  cout << ans << endl;
  return 0;
}