#include <bits/stdc++.h>
using namespace std;
const long long Inf = 1e14;
int n, m, st, ed;
int ned;
int eu[10020], ev[10020];
long long ew[10020];
long long d[10020];
vector<pair<long long, int> > G[10020];
int done[10020];
void dij() {
  for (int i = 0; i < n; i++) d[i] = i == st ? 0 : Inf, done[i] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  q.push(pair<long long, int>(0, st));
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (done[u]) continue;
    done[u] = 1;
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i].second;
      long long w = G[u][i].first;
      if (d[v] > d[u] + w) {
        d[v] = d[u] + w;
        q.push(pair<long long, int>(d[v], v));
      }
    }
  }
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &ned, &st, &ed);
  vector<int> rest;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    eu[i] = u, ev[i] = v, ew[i] = w;
    if (w) {
      G[u].push_back(pair<long long, int>(w, v));
      G[v].push_back(pair<long long, int>(w, u));
    } else
      rest.push_back(i);
  }
  dij();
  if (d[ed] < ned) {
    puts("NO");
    return 0;
  }
  bool flag = 0;
  for (int i = 0; i < rest.size(); i++) {
    if (d[ed] <= ned) {
      ew[rest[i]] = Inf;
      continue;
    }
    int u = eu[rest[i]], v = ev[rest[i]];
    G[u].push_back(pair<long long, int>(1, v));
    G[v].push_back(pair<long long, int>(1, u));
    dij();
    if (d[ed] <= ned) {
      ew[rest[i]] = 1 + ned - d[ed];
    } else {
      ew[rest[i]] = 1;
    }
  }
  if (d[ed] <= ned) {
    puts("YES");
    for (int i = 0; i < m; i++) printf("%d %d %lld\n", eu[i], ev[i], ew[i]);
  } else
    puts("NO");
  return 0;
}
