#include <bits/stdc++.h>
using namespace std;
long long n, head[1005], cnt, dis[1005], vis[1005], m, l, s, t, a[100005],
    b[100005], c[100005], mark[100005];
struct edge {
  long long to, v, next;
} e[200005];
void add(long long a, long long b, long long c) {
  e[cnt].to = b;
  e[cnt].v = c;
  e[cnt].next = head[a];
  head[a] = cnt++;
}
void spfa() {
  queue<long long> q;
  q.push(s);
  memset(dis, 0x3f3f3f, sizeof(dis));
  dis[s] = 0;
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    vis[u] = 0;
    for (long long i = head[u]; i != -1; i = e[i].next) {
      if (e[i].v == 0) continue;
      if (dis[u] + e[i].v < dis[e[i].to]) {
        dis[e[i].to] = dis[u] + e[i].v;
        if (!vis[e[i].to]) {
          vis[e[i].to] = 1;
          q.push(e[i].to);
        }
      }
    }
  }
}
inline void read(long long &x) {
  x = 0;
  char c;
  c = getchar();
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar();
}
inline void write(long long x) {
  long long y = 10, len = 1;
  while (y <= x) {
    y *= 10;
    len++;
  }
  while (len--) {
    y /= 10;
    putchar(x / y + 48);
    x %= y;
  }
  putchar(' ');
}
int main() {
  bool ok = 0;
  read(n);
  read(m);
  read(l);
  read(s);
  read(t);
  memset(head, -1, sizeof(head));
  cnt = 0;
  for (long long i = 0; i < m; ++i) {
    read(a[i]);
    read(b[i]);
    read(c[i]);
    if (c[i] == 0) {
      mark[i] = 1;
      c[i] = 1;
    }
    add(a[i], b[i], c[i]);
    add(b[i], a[i], c[i]);
  }
  spfa();
  if (dis[t] > l) {
    puts("NO");
    return 0;
  }
  if (dis[t] == l) {
    ok = 1;
  }
  long long gg = l - dis[t];
  for (long long i = 0; i < m; ++i) {
    if (ok) break;
    if (!mark[i]) continue;
    e[i * 2].v += gg;
    e[i * 2 + 1].v += gg;
    c[i] += gg;
    spfa();
    if (dis[t] == l) {
      ok = 1;
      break;
    } else
      gg = l - dis[t];
  }
  if (ok) {
    puts("YES");
    for (long long i = 0; i < m; ++i) {
      write(a[i]);
      write(b[i]);
      write(c[i]);
      puts("");
    }
    return 0;
  } else {
    puts("NO");
  }
}
