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;
struct A {
  int fr, to, th;
  long long d;
  A() {}
  A(int a, int b, long long c, int d) : fr(a), to(b), d(c), th(d) {}
};
const int N = 1003;
vector<A> edge, G[N], ze, all;
int from[N];
long long dis[N];
void SPFA(int x) {
  queue<int> q;
  q.push(x);
  for (int i = 0; i < N; ++i) dis[i] = 1e15;
  dis[x] = 0;
  bool inq[N] = {};
  while (!q.empty()) {
    int fr = q.front();
    q.pop();
    inq[fr] = 0;
    for (A e : G[fr]) {
      if (dis[e.to] > dis[e.fr] + e.d) {
        dis[e.to] = dis[e.fr] + e.d;
        if (!inq[e.to]) {
          inq[e.to] = 1;
          q.push(e.to);
        }
        from[e.to] = e.th;
      }
    }
  }
}
int main() {
  int n, m, s, t;
  long long L;
  scanf("%d%d%lld%d%d", &n, &m, &L, &s, &t);
  for (int i = 0, x, y; i < m; ++i) {
    long long d;
    scanf("%d%d%lld", &x, &y, &d);
    if (!d)
      ze.push_back(A(x, y, d, i));
    else
      edge.push_back(A(x, y, d, i));
    all.push_back(A(x, y, d, i));
  }
  for (auto e : edge) {
    G[e.fr].push_back(e);
    G[e.to].push_back(A(e.to, e.fr, e.d, e.th));
  }
  SPFA(s);
  if (dis[t] < L) {
    puts("NO");
    return 0;
  }
  if (dis[t] == L) {
    puts("YES");
    for (auto e : all) {
      printf("%d %d %lld\n", e.fr, e.to, e.d ? e.d : (long long)(1e15));
    }
    return 0;
  }
  for (int i = 0; i < ze.size(); ++i) {
    ze[i].d = 1;
    A& e = ze[i];
    G[e.fr].push_back(e);
    G[e.to].push_back(A(e.to, e.fr, e.d, e.th));
  }
  SPFA(s);
  if (dis[t] > L) {
    puts("NO");
    return 0;
  }
  bool used[10004] = {};
  vector<int> use;
  int p = t;
  while (p != s) {
    if (!all[from[p]].d) use.push_back(from[p]);
    used[from[p]] = 1;
    A& e = all[from[p]];
    p = e.to == p ? e.fr : e.to;
  }
  long long di = (L - dis[t]) / ((int)use.size()),
            mo = (L - dis[t]) % ((long long)use.size());
  all[use[0]].d += di + mo + 1;
  for (int i = 1; i < use.size(); ++i) {
    all[use[i]].d += di + 1;
  }
  for (auto e : all) {
    if (!e.d) all[e.th].d = 1e15;
  }
  puts("YES");
  for (auto e : all) {
    printf("%d %d %lld\n", e.fr, e.to, e.d);
  }
}
