#include <bits/stdc++.h>
const int N = 1010, M = 20010;
const long long inf = 1LL << 50;
int to[M], next[M], head[N], num[M], tot, h, t, n, m, k, q[N + 10];
long long dis[N], ans = inf;
int x[M], y[M], pre[N], d[M], from[M], S, T, L;
bool vis[M], can[M], flag;
void add(const int &x, const int &y, const int &z) {
  to[++tot] = y;
  next[tot] = head[x];
  num[head[x] = tot] = z;
  from[tot] = x;
}
void spfa() {
  memset(pre, -1, sizeof(pre));
  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;
  }
}
void retry() {
  for (int i = T; i != S && pre[i] != -1; i = from[pre[i]])
    vis[pre[i] + 1 >> 1] = 0;
  tot = flag = 0;
  memset(head, 0, sizeof(head));
  for (int i = 1; i <= m; ++i) add(x[i], y[i], d[i]), add(y[i], x[i], d[i]);
  spfa();
  for (int i = T; i != S && pre[i] != -1; i = from[pre[i]]) {
    vis[pre[i] + 1 >> 1] = 1;
    if (can[pre[i] + 1 >> 1]) flag = 1;
  }
}
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;
    else {
      add(x[i], y[i], d[i]);
      add(y[i], x[i], d[i]);
    }
  }
  spfa();
  if (dis[T] < L) {
    puts("NO");
    return 0;
  }
  if (dis[T] == L) {
    puts("YES");
    for (int i = 1; i <= m; ++i) printf("%d %d %d\n", x[i], y[i], d[i]);
    return 0;
  }
  retry();
  if (dis[T] > L) {
    puts("NO");
    return 0;
  }
  while (dis[T] != L) {
    long long del = L - dis[T] + 1;
    for (int i = 1; i <= m; ++i) {
      if (can[i]) {
        if (vis[i] && flag) d[i] = del, flag = 0;
        if (!vis[i]) d[i] = L + 1, can[i] = 0;
      }
    }
    retry();
  }
  puts("YES");
  for (int i = 1; i <= m; ++i) printf("%d %d %d\n", x[i], y[i], d[i]);
  return 0;
}
