#include<bits/stdc++.h> usingnamespace std; #define ll long long #define inf 0x3f3f3f3f #define N 302 #define M 50002 #define K 32
int n, m, e, p, l, t, tot, ans = inf; int to[(M << 1) * K], len[(M << 1) * K], nxt[(M << 1) * K], head[N * K]; int edge[M][3], f[N][N], dis[N * K], vis[N * K];
voidadd(int u, int v, int w){ to[++tot] = v; len[tot] = w; nxt[tot] = head[u]; head[u] = tot; }
voidspfa(int x, int y){ memset(dis, 0x3f, sizeof dis); memset(vis, 0, sizeof vis); queue<int> q; dis[x] = y; q.push(x); while (!q.empty()) { int now = q.front(); q.pop(); vis[now] = 0; for (int i = head[now]; i; i = nxt[i]) if (dis[to[i]] > dis[now] + len[i]) { dis[to[i]] = dis[now] + len[i]; if (!vis[to[i]]) { vis[to[i]] = 1; q.push(to[i]); } } } }
voidfloyd(){ for (int k = 1; k <= n; k++) if (!(dis[k] - dis[k - 1])) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (i != j && i != k && j != k) f[i][j] = min(f[i][j], f[i][k] + f[k][j]); } intmain(){ scanf("%d%d%d%d%d%d", &n, &m, &e, &p, &l, &t); memset(f, 0x3f, sizeof f); for (int i = 1; i <= e; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); edge[i][0] = u; edge[i][1] = v; edge[i][2] = w; f[u][v] = f[v][u] = min(f[u][v], w); } for (int i = 1; i <= p; i++) { int u, v, w; scanf("%d%d%d", &u, &v, &w); add(v, u - 1, -w); } for (int i = 2; i <= n; i++) add(i, i - 1, 0), add(i - 1, i, 1); spfa(n, m); floyd(); memset(head, 0, sizeof head); tot = 0; for (int i = 1; i <= e; i++) for (int k = 0; k <= t; k++) { add(k * n + edge[i][0], k * n + edge[i][1], edge[i][2]); add(k * n + edge[i][1], k * n + edge[i][0], edge[i][2]); } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (i != j && f[i][j] <= l) for (int k = 0; k < t; k++) add(k * n + i, (k + 1) * n + j, 0); spfa(1, 0); for (int k = 0; k <= t; k++) ans = min(ans, dis[k * n + n]); printf("%d\n", ans); return0; }