# library from https://prd-xxx.hateblo.jp/entry/2019/06/24/235844 import heapq class Reverse: def __init__(self, val): self.val = val def __lt__(self, other): return self.val > other.val def __repr__(self): return repr(self.val) class Heapq: def __init__(self, arr, desc = False): if desc: for i in range(len(arr)): arr[i] = Reverse(arr[i]) self.desc = desc self.hq = arr heapq.heapify(self.hq) def pop(self): if self.desc: return heapq.heappop(self.hq).val else: return heapq.heappop(self.hq) def push(self, a): if self.desc: heapq.heappush(self.hq, Reverse(a)) else: heapq.heappush(self.hq, a) def top(self): if self.desc: self.hq[0].val else: return self.hq[0] n,m,p,y = map(int, input().split()) abc = [list(map(int, input().split())) for i in range(m)] de = [list(map(int, input().split())) for i in range(p)] graph = [[] for i in range(n)] for a,b,c in abc: a -= 1 b -= 1 graph[a].append((b,c)) graph[b].append((a,c)) # hachi = [1 << 60 for i in range(n)] # for d,e in de: # d -= 1 # hachi[d] = e state = [1 << 60 for i in range(n)] state[0] = 0 heap = Heapq([], desc=True) heap.push((0, 0)) while heap.hq: cost, city = heap.pop() if state[city] < cost: continue for ncity, nc in graph[city]: ncost = cost + nc if state[ncity] <= ncost: continue state[ncity] = ncost heap.push((ncost, ncity)) ans = 0 for d,e in de: d -= 1 cost = state[d] if cost > y: continue res = y - cost tans = res // e ans = max(ans, tans) print(ans)