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;
const int N = 1e3 + 5;
const int M = 1e4 + 5;
const long long INF = 1e15;
struct node {
  int s, e, next, f, mark;
  long long w;
} edge[M << 1];
int tot;
int first[N], inq[N], pre[N], up[N];
long long dis[N];
void init(int n) {
  tot = 0;
  for (int i = 0; i <= n; i++) first[i] = -1, dis[i] = INF;
}
void add(int u, int v, long long w) {
  int f = !w;
  if (!w) w = INF;
  edge[tot] = (node){u, v, first[u], f, 0, w};
  first[u] = tot++;
  edge[tot] = (node){v, u, first[v], f, 0, w};
  first[v] = tot++;
}
queue<int> q;
void spfa(int st, int ed) {
  while (!q.empty()) q.pop();
  dis[st] = 0;
  inq[st] = 1;
  pre[st] = -1;
  q.push(st);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    inq[u] = 0;
    for (int i = first[u]; i != -1; i = edge[i].next) {
      int v = edge[i].e;
      if (dis[u] + edge[i].w > dis[v]) continue;
      dis[v] = dis[u] + edge[i].w;
      up[v] = i;
      pre[v] = u;
      if (!inq[v]) inq[v] = 1, q.push(v);
    }
  }
}
int n, m, st, ed, u, v;
long long w, L;
int main() {
  scanf("%d%d%I64d%d%d", &n, &m, &L, &st, &ed);
  init(n);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%I64d", &u, &v, &w);
    add(u, v, w);
  }
  spfa(st, ed);
  if (dis[ed] < L) return 0 * puts("NO");
  for (int i = 0; i <= n; i++) dis[i] = INF, inq[i] = 0;
  for (int i = 0; i < tot; i++)
    if (edge[i].w == INF) edge[i].w = 1LL;
  spfa(st, ed);
  if (dis[ed] > L) return 0 * puts("NO");
  while (1) {
    for (int i = 0; i <= n; i++) inq[i] = 0, dis[i] = INF;
    spfa(st, ed);
    if (dis[ed] == L) break;
    for (int i = 0; i < tot; i++)
      if (edge[i].f) edge[i].mark = 0;
    int now = ed, ff = 0;
    long long left = L - dis[ed];
    while (now != st) {
      if (edge[up[now]].f) {
        edge[up[now]].mark = edge[up[now] ^ 1].mark = 1;
        if (!ff) ff = 1, edge[up[now]].w += left, edge[up[now] ^ 1].w += left;
      }
      now = pre[now];
    }
    for (int i = 0; i < tot; i++)
      if (edge[i].f && !edge[i].mark) edge[i].w = INF;
  }
  puts("YES");
  for (int i = 0; i < tot; i += 2)
    printf("%d %d %I64d\n", edge[i].s, edge[i].e, edge[i].w);
  return 0;
}
