from heapq import heappop, heappush N, M, P, Y = map(int, input().split()) g = [[] for _ in range(N)] for _ in range(M): u, v, c = map(int, input().split()) u, v = u - 1, v - 1 g[u].append((v, c)) g[v].append((u, c)) dp = [0] * N dp[0] = Y hq = [(-Y, 0)] while hq: d, u = heappop(hq) d = -d if dp[u] > d: continue for v, c in g[u]: if dp[v] < d - c: dp[v] = d - c heappush(hq, (-(d - c), v)) ans = 0 for _ in range(P): d, e = map(int, input().split()) d -= 1 ans = max(ans, dp[d] // e) print(ans)