#include <bits/stdc++.h>
using namespace std;
int n, m, L, S, T;
int st[20010], ed[20010], w[20010];
int last[1010], tot;
struct edge {
  int t, next, w;
  bool flag;
} e[20010 * 2];
void add(int from, int to, int w) {
  e[++tot].t = to, e[tot].next = last[from], e[tot].w = w, last[from] = tot;
  e[++tot].t = from, e[tot].next = last[to], e[tot].w = w, last[to] = tot;
}
int q[10 * 20010];
long long d[2][1010];
bool in[1010];
void spfa(int s, long long *dis) {
  int l = 0, r = 0;
  for (int i = 0; i < n; i++) dis[i] = 2147483647;
  q[r++] = s, dis[s] = 0;
  while (l < r) {
    int now = q[l++];
    in[now] = false;
    for (int h = last[now]; h; h = e[h].next) {
      int to = e[h].t;
      if (dis[now] + e[h].w < dis[to]) {
        dis[to] = dis[now] + e[h].w;
        if (!in[to]) in[to] = true, q[r++] = to;
      }
    }
  }
}
struct node {
  int id, w;
  node(int _id, int _w) { id = _id, w = _w; }
  friend bool operator<(const node &u, const node &v) { return u.w > v.w; }
};
priority_queue<node> Q;
bool use[1010];
long long dist[1010];
void work(int s) {
  for (int i = 0; i < n; i++) dist[i] = 2147483647;
  dist[s] = 0;
  memset(use, 0, sizeof(use));
  while (!Q.empty()) {
    node now = Q.top();
    Q.pop();
    if (use[now.id]) continue;
    use[now.id] = true;
    for (int h = last[now.id]; h; h = e[h].next) {
      int to = e[h].t;
      if (s == S && e[h].flag) {
        if (dist[now.id] + d[1][to] + e[h].w <= L)
          e[h].w = e[h ^ 1].w = L - dist[now.id] - d[1][to];
      }
      if (dist[now.id] + e[h].w < dist[to]) dist[to] = dist[now.id] + e[h].w;
      Q.push(node(to, dist[to]));
    }
  }
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &L, &S, &T);
  tot = 1;
  for (int i = 1; i <= m; i++) scanf("%d%d%d", &st[i], &ed[i], &w[i]);
  for (int i = 1; i <= m; i++) add(st[i], ed[i], w[i]);
  for (int i = 2; i <= tot; i++)
    if (!e[i].w) e[i].flag = 1;
  for (int i = 2; i <= tot; i++)
    if (!e[i].w) e[i].w = 1;
  Q.push(node(T, 0));
  work(T);
  for (int i = 0; i < n; i++) d[1][i] = dist[i];
  Q.push(node(S, 0));
  work(S);
  for (int i = 2; i <= tot; i += 2)
    if (e[i].flag) w[i / 2] = e[i].w;
  if (dist[T] != L) return puts("NO"), 0;
  puts("YES");
  for (int i = 1; i <= m; i++) printf("%d %d %d\n", st[i], ed[i], w[i]);
  return 0;
}
