from heapq import heappush, heappop INF = 10 ** 18 def dijkstra(s, N): # (始点, ノード数) dist = [INF for _ in range(N)] hq = [(0, s)] dist[s] = 0 seen = [False] * N # ノードが確定済みかどうか while hq: d, v = heappop(hq) # ノードを pop する if seen[v]: continue seen[v] = True for to, cost in G[v]: # ノード v に隣接しているノードに対して if dist[v] + cost < dist[to]: dist[to] = dist[v] + cost heappush(hq, (dist[to], to)) return dist import sys input = sys.stdin.readline N, M, P, Y = map(int, input().split()) G = [[] for _ in range(N)] for _ in range(M): a, b, c = map(int, input().split()) a-=1 b-=1 G[a].append((b, c)) G[b].append((a, c)) D = dict() for _ in range(P): d, e = map(int, input().split()) d-=1 D[d] = e cost = dijkstra(0, N) ans = 0 for i in range(N): if i not in D: continue if Y-cost[i]<=0: continue ans = max(ans, (Y-cost[i])//D[i]) print(ans)