#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, ori;
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] + all[e.th].d) {
        dis[e.to] = dis[e.fr] + all[e.th].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));
    ori.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];
    all[e.th].d = 1;
    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;
  }
  while (dis[t] != L) {
    vector<int> use;
    bool used[10004] = {};
    int p = t;
    while (p != s) {
      if (!ori[from[p]].d) {
        use.push_back(from[p]);
        used[from[p]] = 1;
      }
      A e = ori[from[p]];
      p = p == e.fr ? e.to : e.fr;
    }
    long long di = (L - dis[t]) / use.size(), mo = (L - dis[t]) % use.size();
    all[use[0]].d += di + mo;
    for (int i = 1; i < use.size(); ++i) all[use[i]].d += di;
    for (auto i : ze)
      if (!used[i.th]) all[i.th].d = 1e15;
    SPFA(s);
  }
  puts("YES");
  for (auto e : all) {
    printf("%d %d %lld\n", e.fr, e.to, e.d);
  }
}
