#include #include using namespace std; using namespace atcoder; using mint = modint998244353; //using mint = modint1000000007; using ll = long long; ll INF = 2e18; template using vc = vector; template using vv = vc>; using vi = vc; using vvi = vv; using vl = vc; using vvl = vv; using vs = vc; using vvs = vv; using vb = vc; using vvb = vv; using vmint = vc; using vvmint = vv; #define rep(i,n) for(ll i=0; i<(n); i++) #define drep(i,n) for(ll i=(n)-1; i>=0; i--) #define rrep(i,n) for(ll i=1; i<=(n); i++) #define nfor(i,a,b) for(ll i=a;i=(b); i--) templateistream& operator>>(istream& i, vc& v) {rep(j,(ll) size(v))i >> v[j]; return i; } #define nall(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define chmax(x,y) x = max(x,y) #define chmin(x,y) x = min(x,y) #define YES cout<<"Yes"<; int main(){ ll N, M, P, Y; cin >> N >> M >> P >> Y; vv edge(N); rep(i,M) { ll a, b, c; cin >> a >> b >> c; a--,b--; edge[a].push_back({b,c}); edge[b].push_back({a,c}); } vl cost(N); rep(i,P) { ll d, e; cin >> d >> e; cost[d-1] = e; } vl distances(N,INF); distances[0] = 0; priority_queue,greater> pq; pq.push({0,0}); while(pq.size()>0) { ll distance = pq.top().first; ll from = pq.top().second; pq.pop(); if (distance != distances[from]) continue; for (auto e : edge[from]) { ll d = e.second + distance; if (d