import java.util.*; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int p = sc.nextInt(); long y = sc.nextLong(); Dijkstra djk = new Dijkstra(n); long[] t = new long[n + 1]; for(int i = 1;i <= n;i++) { t[i] = Long.MAX_VALUE; } for(int i = 0;i < m;i++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); djk.addLine(a, b, c); djk.addLine(b, a, c); }for(int i = 0;i < p;i++) { int d = sc.nextInt(); t[d] = sc.nextLong(); } djk.solve(1,0); long ans = 0; for(int i = 1;i <= n;i++) { long comp = Math.max(0, y - djk.min[i])/t[i]; ans = Math.max(ans, comp); }System.out.print(ans); }public static class Dijkstra { public PriorityQueue q = new PriorityQueue<>(); public long[] min; public boolean[] vis; public HashMap> nextNode = new HashMap<>(); public int n; public Dijkstra(int n) { this.n = n; min = new long[n + 1]; vis = new boolean[n + 1]; for(int i = 1;i <= n;i++) { min[i] = Long.MAX_VALUE/2; nextNode.put(i, new HashSet<>()); } }public void addLine(int from,int to,long cost) { nextNode.get(from).add(new Pair(cost,to)); } public void solve(int ind,long val) { min[ind] = val; q.add(new Pair(val,ind)); while(!q.isEmpty()) { Pair p = q.poll(); if(vis[p.x])continue; vis[p.x] = true; for(Pair s:nextNode.get(p.x)) { if(min[s.x] > min[p.x] + s.v) { min[s.x] = min[p.x] + s.v; q.add(new Pair(min[s.x],s.x)); } } } }public long getMin(int a) { return min[a]; } public static class Pair implements Comparable { long v; int x; public Pair(long a,int b) { v = a; x = b; }public int compareTo(Pair p) { if(this.v < p.v) { return -1; }if(this.v > p.v) { return 1; }return 0; }public boolean equals(Object o) { Pair p = (Pair)o; return p.x == this.x && p.v == this.v; } } } }