import sys; input = sys.stdin.readline from heapq import *; from array import * N, P, M, U, T = map(int, input().split()); INF = 10**9 B = {0}; G = [[] for _ in range(N)] for _ in range(P): v, t = map(int, input().split()) U -= t; B.add(v) for _ in range(M): s, d, t = map(int, input().split()) G[s] += [(d, t)]; G[d] += [(s, t)] def dijkstra(s): D = array('i', [INF]*N); D[s] = 0; pq = [s] while pq: dv = heappop(pq); dd, vv = dv//N, dv%N if dd != D[vv]: continue for nn, w in G[vv]: if D[nn] > (new:=dd+w): D[nn] = new; heappush(pq, new*N+nn) return D B = sorted(B); E = [dijkstra(v) for v in B] G = [[e[b] for b in B] for e in E] from itertools import combinations def tsp(G): n = len(G); C = [[INF for _ in range(2*n)] for _ in range(1<U])