#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, m, l, second, t;
  cin >> n >> m >> l >> second >> t;
  vector<pair<ll, ll> > g[n];
  pair<pair<ll, ll>, pair<ll, ll> > e[m];
  map<pair<ll, ll>, ll> M;
  for (int i = 0; i < m; i++) {
    cin >> e[i].first.first >> e[i].first.second >> e[i].second.first;
    M[{e[i].first.first, e[i].first.second}] = i;
    M[{e[i].first.second, e[i].first.first}] = i;
    e[i].second.second = (e[i].second.first == 0);
    if (e[i].second.first == 0) e[i].second.first = 1;
    g[e[i].first.first].push_back({e[i].first.second, i});
    g[e[i].first.second].push_back({e[i].first.first, i});
  }
  while (1) {
    ll dis[n];
    ll par[n];
    for (int i = 0; i < n; i++) {
      dis[i] = LLONG_MAX / 2;
      par[i] = -1;
    }
    dis[second] = 0;
    set<pair<ll, ll> > se;
    se.insert({0, second});
    while (!se.empty()) {
      pair<ll, ll> p = *(se.begin());
      se.erase(se.begin());
      ll cd = p.first, cu = p.second;
      for (auto v : g[cu]) {
        if (dis[v.first] > cd + e[v.second].second.first) {
          dis[v.first] = cd + e[v.second].second.first;
          se.insert({dis[v.first], v.first});
          par[v.first] = cu;
        }
      }
    }
    if (dis[t] == l) {
      cout << "YES" << endl;
      for (int i = 0; i < m; i++) {
        cout << e[i].first.first << " " << e[i].first.second << " "
             << e[i].second.first << endl;
      }
      return 0;
    }
    if (dis[t] > l) {
      cout << "NO";
      return 0;
    }
    ll flag = 0;
    ll cur = t;
    while (par[cur] != -1) {
      ll ind = M[{par[cur], cur}];
      if (e[ind].second.second) {
        flag = 1;
        e[ind].second.first += l - dis[t];
        break;
      }
      cur = par[cur];
    }
    if (!flag) {
      cout << "NO";
      return 0;
    }
  }
}
