N,M,p,X=map(int,input().split()) G=[[] for i in range(N)] for i in range(M): a,b,c=map(int,input().split()) G[a-1].append((b-1,c)) G[b-1].append((a-1,c)) A=[10**18]*N for i in range(p): d,e=map(int,input().split()) A[d-1]=e result=0 from heapq import heappush,heappop S=[] dp=[10**18]*N dp[0]=0 heappush(S,0) kaku=[False]*N while S: w=heappop(S) time=w//(10**6) pos=w%(10**6) if kaku[pos]==True: continue kaku[pos]=True for B in G[pos]: z,c=B[:] if dp[z]>dp[pos]+c: dp[z]=dp[pos]+c heappush(S,dp[z]*10**6+z) for i in range(N): rest=X-dp[i] result=max(result,rest//A[i]) print(result)