from heapq import heappop, heappush INF = 10**18 def dijkstra(start, graph): n = len(graph) dist = [INF] * n dist[start] = 0 pq = [(0, start)] while pq: now_d, now_v = heappop(pq) if now_d > dist[now_v]: continue for next_v, cost in graph[now_v]: next_d = now_d + cost if next_d < dist[next_v]: dist[next_v] = next_d heappush(pq, (next_d, next_v)) return dist N, M, P, Y = map(int, input().split()) graph = [[] for _ in range(N)] for _ in range(M): A, B, C = map(int, input().split()) graph[A - 1].append((B - 1, C)) graph[B - 1].append((A - 1, C)) shops = [INF] * N for _ in range(P): D, E = map(int, input().split()) shops[D - 1] = min(shops[D - 1], E) dist = dijkstra(0, graph) ans = 0 for i in range(N): if shops[i] < INF and dist[i] <= Y: ans = max(ans, (Y - dist[i]) // shops[i]) print(ans)