#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)

template<typename T>
bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; }
template<typename T>
bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; }

struct io_setup {
	io_setup() {
		ios::sync_with_stdio(false);
		std::cin.tie(nullptr);
		cout << fixed << setprecision(15);
	}
} io_setup;

int main(){
	ll n,m,p,y;
	cin>>n>>m>>p>>y;
	vector<vector<pair<ll,ll>>> g(n);
	rep(i,0,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--; b--;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	vector<int> d(p),e(p);
	rep(i,0,p) cin>>d[i]>>e[i];
	rep(i,0,p) d[i]--;
	priority_queue<pair<ll,ll>> pq;
	vector<ll> cost(n,-1);
	pq.push({y,0});
	while(!pq.empty()){
		auto[cs,nw]=pq.top();
		pq.pop();
		if(cost[nw]!=-1) continue;
		cost[nw]=cs;
		for(auto[nx,ad]:g[nw]){
			if(cost[nx]!=-1) continue;
			pq.push({max(0ll,cs-ad),nx});
		}
	}
	ll ans=0;
	rep(i,0,p){
		chmax(ans,cost[d[i]]/e[i]);
	}
	cout<<ans<<"\n";
}