import heapq
def dijkstra(s):
    hq=[(0,s,0)]
    ans=[]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost=[float('inf')]*N # 行ったことのないところはinf
    cost[s]=0 # 開始地点は0
    while hq:
      c,v,pre=heapq.heappop(hq)
      if c>cost[v]: # コストが現在のコストよりも高ければスルー v:now u:nex
        continue
      for d, u in E[v]:
        tmp=d+cost[v]
        if tmp<cost[u]:
          cost[u]=tmp
          heapq.heappush(hq,(tmp,u,v))
    return cost

N,M,P,Y=map(int,input().split())
E=[[] for _ in range(N)]
for i in range(M):
  a,b,t=map(int,input().split())
  a-=1
  b-=1
  E[a].append((t,b))
  E[b].append((t,a))

A=dijkstra(0)
ans=0
for i in range(P):
  d,e=map(int,input().split())
  c=max(0,Y-A[d-1])//e
  ans=max(ans,c)
print(ans)