#include <bits/stdc++.h>
using namespace std;
long long ans, n, m, second;
long long w2[1005][1005], inf = 1e17, w[1005], ww[10005];
vector<pair<long long, long long> > e;
vector<long long> ad[1005];
set<pair<long long, long long> > ms;
void first(long long x) {
  for (long long i = 0; i < m; i++) {
    if (!ww[i]) {
      w2[e[i].first][e[i].second] = x / ans;
      w2[e[i].second][e[i].first] = x / ans;
      if (x % ans) {
        x--;
        w2[e[i].first][e[i].second]++;
        w2[e[i].second][e[i].first]++;
      }
    }
  }
  return;
}
void dij() {
  memset(w, 63, sizeof w);
  ms.clear();
  w[second] = 0;
  for (long long i = 0; i < n; i++) ms.insert({w[i], i});
  while ((long long)ms.size()) {
    long long v = (*(ms.begin())).second;
    ms.erase(ms.begin());
    for (long long i = 0; i < (long long)ad[v].size(); i++) {
      long long u = ad[v][i];
      if (w[u] > w[v] + w2[v][u]) {
        ms.erase({w[u], u});
        w[u] = w[v] + w2[v][u];
        ms.insert({w[u], u});
      }
    }
  }
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long L, t, u, v;
  cin >> n >> m >> L >> second >> t;
  for (long long i = 0; i < m; i++) {
    cin >> u >> v >> ww[i];
    ad[u].push_back(v);
    ad[v].push_back(u);
    w2[u][v] = w2[v][u] = ww[i];
    e.push_back({u, v});
    if (!ww[i]) ans++;
  }
  long long l = ans, r = 1e18;
  while (r - l > 1) {
    long long mid = (r + l) / 2;
    first(mid);
    dij();
    if (w[t] > L)
      r = mid;
    else
      l = mid;
  }
  first(l);
  dij();
  if (w[t] != L) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (long long i = 0; i < m; i++)
    cout << e[i].first << " " << e[i].second << " "
         << w2[e[i].first][e[i].second] << endl;
  return 0;
}
