#include <bits/stdc++.h>
using namespace std;
const int N = 10005, M = 100005, mod = 1e9 + 7;
template <class T>
inline void gmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <class T>
inline void gmax(T &x, const T &y) {
  if (x < y) x = y;
}
inline void ch(int &x, int y) { x = (x + y) % mod; }
template <class T>
inline void read(T &x) {
  x = 0;
  char ch = getchar(), rev = 0;
  while (ch > '9' || ch < '0') rev = (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x = rev ? -x : x;
}
template <class T>
inline void print(T x) {
  if (!x) {
    puts("0");
    return;
  }
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  int a[20], m = 0;
  while (x) a[m++] = x % 10, x /= 10;
  while (m--) putchar(a[m] + '0');
  puts("");
}
inline int exp(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = (long long)ans * x % mod;
    x = (long long)x * x % mod;
    y >>= 1;
  }
  return ans;
}
struct node {
  int to, next, w;
} p[N << 1];
int tot, head[N], vis[N], a[N], l[N];
int n, m, L, S, T, u[N], v[N], w[N], to[N], from[N];
long long d[N], ds[N], dt[N];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
void add(int x, int y, int z) {
  p[++tot] = (node){y, head[x], z};
  head[x] = tot;
  p[++tot] = (node){x, head[y], z};
  head[y] = tot;
}
void dijstra(long long *d) {
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) d[i] = 0x3f3f3f3f;
  d[S] = 0;
  q.push(make_pair(0, S));
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    for (int i = head[x]; i; i = p[i].next) {
      int y = p[i].to;
      if (d[y] > d[x] + p[i].w) {
        d[y] = d[x] + p[i].w;
        from[y] = i;
        to[y] = x;
        q.push(make_pair(d[y], y));
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  read(n);
  read(m);
  read(L);
  read(S);
  read(T);
  S++;
  T++;
  tot = 1;
  for (int i = 1; i <= m; i++) {
    read(u[i]);
    read(v[i]);
    read(w[i]);
    u[i]++;
    v[i]++;
    if (w[i])
      add(u[i], v[i], w[i]);
    else
      add(u[i], v[i], 0x3f3f3f3f);
  }
  dijstra(ds);
  swap(S, T);
  dijstra(dt);
  swap(S, T);
  if (ds[T] < L) {
    puts("NO");
    return 0;
  }
  if (ds[T] == L) {
    puts("YES");
    for (int i = 1; i <= m; i++)
      printf("%d %d %d\n", u[i] - 1, v[i] - 1, w[i] ? w[i] : 0x3f3f3f3f);
    return 0;
  }
  for (int i = 1; i <= tot; i++)
    if (p[i].w == 0x3f3f3f3f) p[i].w = 1;
  dijstra(d);
  if (d[T] > L) {
    puts("NO");
    return 0;
  }
  int k = T, tot = 0;
  while (k != S) a[++tot] = k, k = to[k];
  reverse(a + 1, a + tot + 1);
  int now = 0;
  for (int i = 1; i <= tot; i++) {
    int x = from[a[i]] >> 1;
    if (!w[x]) w[x] = max(1ll, L - dt[a[i]] - now);
    now += w[x];
    if (now == L - dt[a[i]]) break;
  }
  puts("YES");
  for (int i = 1; i <= m; i++)
    printf("%d %d %d\n", u[i] - 1, v[i] - 1, w[i] ? w[i] : 0x3f3f3f3f);
  return 0;
}
