import heapq N, M, P, Y = map(int, input().split()) edges = [list(map(int, input().split())) for _ in range(M)] shops = [list(map(int, input().split())) for _ in range(P)] C = 10**18 Cost = [C]*N graph = [[] for _ in range(N)] for a, b, c in edges: graph[b-1].append((a-1, c)) graph[a-1].append((b-1, c)) heap = [(0, 0)] Cost[0] = 0 visited = [False]*N while heap: c, x = heapq.heappop(heap) if visited[x]: continue visited[x] = True for u, c2 in graph[x]: if not visited[u] and c + c2 < Cost[u]: heapq.heappush(heap, [c+c2, u]) Cost[u] = c+c2 answer = 0 for d, e in shops: remain = max(Y-Cost[d-1], 0) answer = max(remain//e, answer) print(answer)