from collections import deque, defaultdict
from heapq import heappop, heappush
INF = 1<<60

N, M, P, Y = map(int, input().split())

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

vis = [INF]*N
q = [(0, 0)]
while q:
    cost, i = heappop(q)
    if vis[i] < cost: continue
    vis[i] = cost
    for j, c in E[i]:
        if vis[j] <= cost+c: continue
        heappush(q, (cost+c, j))

ans = 0
for _ in range(P):
    d, e = map(int, input().split())
    d = d-1
    money = Y-vis[d]
    ans = max(ans, money//e)
print(ans)