from heapq import heapify,heappush, heappop def dijkstra(G, s): INF = 10**18 dist = [[INF,INF] for _ in range(N)] dist[s][0] = 0 pq = [(0, s, 10**18)] heapify(pq) while pq: d, v, c = heappop(pq) if d > dist[v][0]: continue for u, weight in G[v]: nd = d + weight if dist[u][0] > nd: dist[u][0] = nd m = 10**18 if u in D: m = D[u] dist[u][1] = min(dist[u][1],m) heappush(pq, (nd, u, min(c,m))) return dist N,M,P,Y = map(int,input().split()) G = [set() for _ in range(N)] for _ in range(M): a,b,c = map(int,input().split()) a,b = a-1,b-1 G[a].add((b,c)) G[b].add((a,c)) D = dict() for _ in range(P): d,e = map(int,input().split()) D[d-1] = e L = dijkstra(G,0) if 0 in D: L[0][1] = D[0] Ans = 0 for c,m in L: Ans = max(Ans,(Y-c)//m) print(Ans)