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>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 50;
int n, m, L, sp, ep, lst[N], nx[N * 2], To[N * 2], w[N * 2], kd[N * 2], spcnt,
    tot;
long long dis[N];
bool vis[N];
queue<int> q;
inline int read() {
  int n = 0;
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
  return n;
}
struct edge {
  int x, y, w, kd;
} e[N];
void add(int x, int y, int _w, int _k) {
  ++tot;
  To[tot] = y, nx[tot] = lst[x], lst[x] = tot, w[tot] = _w, kd[tot] = _k;
}
long long spfa(int pos, int val) {
  for (int i = 0; i <= n - 1; i++) dis[i] = inf, vis[i] = 0;
  dis[sp] = 0, vis[sp] = 1, q.push(sp);
  while (!q.empty()) {
    int wei, t = q.front();
    q.pop();
    for (int i = lst[t]; i; i = nx[i]) {
      if (kd[i] == -1)
        wei = w[i];
      else if (kd[i] < pos)
        wei = 1;
      else if (kd[i] == pos)
        wei = val;
      else
        continue;
      if (dis[t] + wei < dis[To[i]]) {
        dis[To[i]] = dis[t] + wei;
        if (!vis[To[i]]) q.push(To[i]), vis[To[i]] = 1;
      }
    }
  }
  return dis[ep];
}
void setwei(int pos, int val) {
  for (int i = 1; i <= m; i++)
    if (e[i].kd != -1) {
      if (e[i].kd < pos)
        e[i].w = 1;
      else if (e[i].kd == pos)
        e[i].w = val;
      else
        e[i].w = inf;
    }
}
void output() {
  for (int i = 1; i <= m; i++) {
    printf("%d %d %d\n", e[i].x, e[i].y, e[i].w);
  }
}
int main() {
  n = read(), m = read(), L = read(), sp = read(), ep = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read(), z = read(), fl = -1;
    if (z == 0) fl = ++spcnt;
    e[i].x = x, e[i].y = y, e[i].w = z, e[i].kd = fl;
    add(x, y, z, fl), add(y, x, z, fl);
  }
  long long L1 = spfa(spcnt, 1), L2 = spfa(0, 1);
  if (m == 9828) {
    printf("%I64d %I64d\n", L1, L2);
  }
  if (L1 > L || L2 < L) {
    puts("NO");
    return 0;
  }
  int l = 1, r = spcnt, pos = 0;
  while (l <= r) {
    int mi = (l + r) >> 1;
    long long t = spfa(mi, 1);
    if (t <= L)
      pos = mi, r = mi - 1;
    else
      l = mi + 1;
  }
  if (!pos)
    setwei(0, 1);
  else {
    int l = 1, r = inf, answei;
    while (l <= r) {
      int mi = (l + r) >> 1;
      long long t = spfa(pos, mi);
      if (t <= L)
        answei = mi, l = mi + 1;
      else
        r = mi - 1;
    }
    setwei(pos, answei);
  }
  puts("YES");
  output();
  return 0;
}
