import sys
input = sys.stdin.readline

from heapq import heappush, heappop
inf = float('inf')

def dijkstra(s, g, N):
    # ゴールがない場合はg=-1とする。

    def cost(v, m):
        return v * N + m

    dist = [inf] * N
    mindist = [inf] * N
    seen = [False] * N
    Q = [cost(0, s)]
    while Q:
        c, m = divmod(heappop(Q), N)
        if seen[m]:
            continue
        seen[m] = True
        dist[m] = c
        if m == g:
            return dist

        #------heapをアップデートする。--------
        for u, C in G[m]:
            if seen[u]:
                continue
            newdist = dist[m] + C

            #------------------------------------
            if newdist >= mindist[u]:
                continue
            mindist[u] = newdist
            heappush(Q, cost(newdist, u))
    return dist



N, M, P, Y = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append((b, c))
    G[b].append((a, c))
    
inf = 10 ** 18 + 5
hachi = [inf] * N
for i in range(P):
    d, e = map(int, input().split())
    hachi[d - 1] = e
    
D = dijkstra(0, -1, N)
ans = 0
for i in range(N):
    ans = max(ans, (Y - D[i])//hachi[i])
    
print(ans)