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;
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;
}
