7 9 999999999 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 7 9 320 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 4 5 7 0 3
0 1 0
1 2 3
2 3 0
0 2 5
1 3 5
 8 9 10 1 0
1 2 1
2 4 1
1 3 0
3 4 0
4 5 0
5 6 1
6 0 1
5 7 0
7 0 0
 4 4 14 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 5 6 1000000000 0 4
0 1 1
2 0 2
3 0 3
4 1 0
4 2 0
3 4 0
 4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
 4 4 2 1 3
1 3 13
2 3 0
2 0 0
1 0 0
 5 5 2 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 5 5 3 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 4 4 8 1 3
1 3 13
2 3 0
2 0 0
1 0 6
 1000 1 1000000000 998 0
0 999 0
 5 5 1 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 100 1 123456 99 0
0 99 123456
 4 4 13 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 7 9 319 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 1000 1 5 999 0
0 999 0

YES
0 1 1
1 2 999999996
2 3 999999997
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 YES
0 1 1
1 2 199
2 3 318
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 1 3
1 2 3
2 3 2
0 2 5
1 3 5
 YES
1 2 1
2 4 1
1 3 1
3 4 1
4 5 6
5 6 1
6 0 1
5 7 1
7 0 1
 NO YES
0 1 1
2 0 2
3 0 3
4 1 999999999
4 2 999999998
3 4 999999997
 NO NO YES
0 1 1
1 2 1
0 4 1
4 3 1
3 2 1
 NO YES
1 3 13
2 3 1
2 0 1
1 0 6
 NO NO YES
0 99 123456
 YES
1 3 13
2 3 1
2 0 1
1 0 12
 YES
0 1 1
1 2 198
2 3 317
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 999 5

#include <bits/stdc++.h>
const int N = 20020;
const long long inf = 1LL << 50;
inline int min(int a, int b) { return a < b ? a : b; }
inline int max(int a, int b) { return a > b ? a : b; }
inline int abs(int a) { return a < 0 ? -a : a; }
int to[N], next[N], head[N], tot, h, t, n, m, k, q[N + 10], num[N];
long long dis[N], ans = inf;
int x[N], y[N], d[N], pre[N], from[N], S, T, L;
bool vis[N], dt[N], can[N], flag;
void add(int x, int y, int z) {
  to[++tot] = y;
  next[tot] = head[x];
  num[head[x] = tot] = z;
  from[tot] = x;
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &L, &S, &T);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", x + i, y + i, d + i);
    if (d[i] == 0) d[i] = can[i] = 1;
    add(x[i], y[i], d[i]);
    add(y[i], x[i], d[i]);
  }
  for (int i = 0; i <= n; ++i) dis[i] = inf;
  vis[S] = 1;
  for (dis[q[h = t = 1] = S] = 0; h != (t + 1) % N; h = (h + 1) % N) {
    for (int i = head[q[h]]; i; i = next[i])
      if (dis[q[h]] + num[i] < dis[to[i]]) {
        dis[to[i]] = dis[q[h]] + num[i];
        pre[to[i]] = i;
        if (!vis[to[i]]) vis[q[t = (t + 1) % N] = to[i]] = 1;
      }
    vis[q[h]] = 0;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = T; i != S; i = from[pre[i]]) {
    vis[pre[i] + 1 >> 1] = 1;
    if (can[pre[i] + 1 >> 1]) flag = 1;
  }
  if (dis[T] == L) {
    puts("YES");
    for (int i = 1; i <= m; ++i) printf("%d %d %d\n", x[i], y[i], d[i]);
  } else if (dis[T] < L && flag) {
    puts("YES");
    int del = L - dis[T] + 1;
    for (int i = 1; i <= m; ++i) {
      if (can[i]) {
        if (vis[i] && flag) {
          printf("%d %d %d\n", x[i], y[i], del);
          flag = 0;
        } else
          printf("%d %d 9999999999999\n", x[i], y[i]);
      } else
        printf("%d %d %d\n", x[i], y[i], d[i]);
    }
  } else
    puts("NO");
  return 0;
}
