import heapq INF = 10**20 n, m, p, y = map(int, input().split()) edges = [[] for _ in range(n)] for _ in range(m): a, b, c = map(int, input().split()) a, b = a - 1, b - 1 edges[a].append((c, b)) edges[b].append((c, a)) stores = [INF] * n for _ in range(p): d, e = map(int, input().split()) stores[d - 1] = e ans = 0 dist = [INF] * n dist[0] = 0 que = [(0, 0)] while que: cost, crt = heapq.heappop(que) if dist[crt] < cost: continue tmp = max(0, y - cost) // stores[crt] ans = max(ans, tmp) for nxt_cost, nxt in edges[crt]: if dist[nxt] <= cost + nxt_cost: continue dist[nxt] = cost + nxt_cost heapq.heappush(que, (dist[nxt], nxt)) print(ans)