#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1010, inf = 1e18;
vector<pair<long long, long long>> ed, q;
vector<long long> adj[MAXN];
long long ww[MAXN], W[MAXN][MAXN];
long long n, ms, t, m;
set<pair<long long, long long>> s;
void fill() {
  memset(ww, 63, sizeof ww);
  ww[ms] = 0;
  for (long long i = 0; i < n; i++) {
    s.insert(make_pair(ww[i], i));
  }
  return;
}
void dijkstra() {
  fill();
  while (s.size()) {
    set<pair<long long, long long>>::iterator it;
    it = s.begin();
    long long u = it->second;
    s.erase(s.begin());
    for (long long i = 0; i < adj[u].size(); i++) {
      long long v = adj[u][i];
      if (ww[u] + W[u][v] < ww[v]) {
        s.erase(make_pair(ww[v], v));
        ww[v] = ww[u] + W[u][v];
        s.insert(make_pair(ww[v], v));
      }
    }
  }
  return;
}
int32_t main() {
  long long ml;
  cin >> n >> m >> ml >> ms >> t;
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back(v);
    adj[v].push_back(u);
    W[u][v] = W[v][u] = w;
    ed.push_back(make_pair(u, v));
    if (w == 0) {
      q.push_back(make_pair(u, v));
    }
  }
  long long r = inf, l = q.size();
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    long long x = mid;
    for (long long i = 0; i < q.size(); i++) {
      long long f = q[i].first, se = q[i].second;
      W[f][se] = x / q.size();
      W[se][f] = x / q.size();
      if (x % q.size() != 0) {
        x--;
        W[f][se]++;
        W[se][f]++;
      }
    }
    dijkstra();
    if (ww[t] <= ml)
      l = mid;
    else
      r = mid;
  }
  for (long long i = 0; i < q.size(); i++) {
    long long f = q[i].first, se = q[i].second;
    W[f][se] = l / q.size();
    W[se][f] = l / q.size();
    if (l % q.size() != 0) {
      l--;
      W[f][se]++;
      W[se][f]++;
    }
  }
  dijkstra();
  if (ww[t] != ml) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (long long i = 0; i < m; i++) {
    long long f = ed[i].first, s = ed[i].second;
    cout << f << " " << s << " " << W[f][s] << endl;
  }
  return 0;
}
