//#pragma GCC optimize("Ofast") //#pragma GCC optimize "O3,omit-frame-pointer,inline" #include // cout, endl, cin #include // string, to_string, stoi #include // vector #include // min, max, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower #include //fixed,setprecision #include //INT_MAX #include //M_PI #include #include // 正規表現 #include #include #include #include #include #include #include #include //複素数 //#include using namespace std; #include using namespace atcoder; using mint = modint998244353; using ll = long long; using ull = unsigned long long; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const int dx[4] = {0, 1, 0, -1}; const int dy[4] = {1, 0, -1, 0}; random_device rnd; mt19937 mt_gen(rnd()); int RandInt(int a, int b) { return a + mt_gen() % (b - a + 1); } struct edge{ ll to,cost; }; ll n,m,p,y; vectorto[202020]; ll ans_cnt=0; ll goal=-1; void dijkstra(ll s, vector&d){ priority_queue,vector>,greater>>pq; d[s]=0; pq.push({0,s}); while(!pq.empty()){ pairp=pq.top(); pq.pop(); ll v=p.second; if(d[v]d[v]+e.cost){ d[e.to]=d[v]+e.cost; pq.push({d[e.to],e.to}); } } } } int main(){ cin>>n>>m>>p>>y; rep(i,m){ ll a,b,c; cin>>a>>b>>c; a--;b--; to[a].push_back({b,c}); to[b].push_back({a,c}); } vector>shop(p); rep(i,p){ cin>>shop[i].second>>shop[i].first; shop[i].second--; } sort(shop.begin(),shop.end()); goal=shop[0].second; vectord(n,1e18); dijkstra(0,d); rep(i,p){ if(y-d[shop[i].second]>0){ ans_cnt=max(ans_cnt,(y-d[shop[i].second])/shop[i].first); } } cout<