from heapq import heappop, heappush def readints(): return list(map(int, input().split())) def deep_recursion(): import sys import pypyjit # type: ignore sys.setrecursionlimit(550000) pypyjit.set_param('max_unroll_recursion=-1') def main(): N, M, P, Y = readints() adj = [[] for _ in range(N)] for _ in range(M): a, b, c = readints() a -= 1 b -= 1 adj[a].append((b, c)) adj[b].append((a, c)) store = {} for _ in range(P): d, e = readints() store[d-1] = e INF = 10**18 dist = [INF] * N dist[0] = 0 q = [(0, 0)] ans = 0 while q: d, u = heappop(q) if d > dist[u]: continue if u in store: ans = max(ans, max(Y - d, 0) // store[u]) for v, c in adj[u]: if dist[u] + c < dist[v]: dist[v] = dist[u] + c heappush(q, (dist[v], v)) print(ans) if __name__ == '__main__': # deep_recursion() main()