from heapq import heappush, heappop def main(): N, M, P, Y = map(int, input().split()) G = [[] for _ in range(N)] V = [10**18 + 1] * 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)) for _ in range(P): D, E = map(int, input().split()) D -= 1 V[D] = E D = [10**18] * N D[0] = 0 pq = [(0, 0)] while pq: d, u = heappop(pq) if D[u] < d: continue for v, c in G[u]: if D[v] <= d+c: continue D[v] = d+c heappush(pq, (d+c, v)) ans = max(max(Y-D[i], 0) // V[i] for i in range(N)) print(ans) main()