import heapq import queue N , M , Q , Y = map( int , input().split() ) R = [ [] for _ in range(N) ] for _ in range(M) : a , b , c = map( int , input().split() ) a -= 1 b -= 1 R[a].append([b,c]) R[b].append([a,c]) INF = 10**20 P = [ INF ] * N for _ in range(Q) : d , e = map( int , input().split() ) P[d-1] = e check = [ True ] * N num = [ 0 ] * N dis = [ -1 ] * N num[0] = Y // P[0] dis[0] = 0 s = [] heapq.heappush( s , [ 0 , 0 ] ) while len(s) != 0 : d , p = heapq.heappop( s ) if check[p] : dis[p] = d num[p] = ( Y - d ) // P[p] check[p] = False for q , c in R[p] : if check[q] : heapq.heappush( s , [ d + c , q ] ) print( max(num) )