#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e3 + 13;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
template <typename T, typename... Args>
inline string arrStr(T arr, long long n) {
  stringstream s;
  s << "[";
  for (long long i = 0; i < n - 1; i++) s << arr[i] << ",";
  s << arr[n - 1] << "]";
  return s.str();
}
inline void __evars_begin(long long line) { cerr << "#" << line << ": "; }
template <typename T>
inline void __evars_out_var(vector<T> val) {
  cerr << arrStr(val, val.size());
}
template <typename T>
inline void __evars_out_var(T *val) {
  cerr << arrStr(val, 10);
}
template <typename T>
inline void __evars_out_var(T val) {
  cerr << val;
}
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template <typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
  __evars_out_var(a);
  cerr << "; ";
  __evars(++it, args...);
}
long long n, m, l, sr, dt;
vector<long long> dist, wt, par;
vector<pair<long long, long long>> adj[N], e;
void geta() {
  dist.resize(n);
  for (long long &x : dist) x = mod;
  dist[sr] = 0;
  set<pair<long long, long long>> s;
  s.insert({0, sr});
  vector<long long> id(n);
  id[sr] = -1;
  while (!s.empty()) {
    auto p = *s.begin();
    s.erase(s.begin());
    for (auto &x : adj[p.second]) {
      if (dist[x.first] > p.first + wt[x.second]) {
        s.erase({dist[x.first], x.first});
        dist[x.first] = p.first + wt[x.second];
        id[x.first] = x.second;
        s.insert({dist[x.first], x.first});
      }
    }
  }
  par.clear();
  if (dist[dt] == mod) return;
  long long cur = dt;
  while (id[cur] != -1) {
    par.push_back(id[cur]);
    cur = cur ^ e[id[cur]].first ^ e[id[cur]].second;
  }
}
void kudne() {
  cin >> n >> m >> l >> sr >> dt;
  wt.resize(m);
  e.resize(m);
  unordered_map<long long, long long> v;
  for (long long i = 0; i < m; ++i) {
    cin >> e[i].first >> e[i].second >> wt[i];
    if (!wt[i]) v[i]++;
    adj[e[i].first].push_back({e[i].second, i});
    adj[e[i].second].push_back({e[i].first, i});
  }
  for (auto &x : v) wt[x.first] = mod;
  geta();
  if (dist[dt] < l) {
    cout << "NO";
    return;
  }
  for (auto &x : v) wt[x.first] = 1;
  geta();
  if (dist[dt] > l) {
    cout << "NO";
    return;
  }
  for (auto &x : v) wt[x.first] = mod;
  for (long long x : par)
    if (v[x]) wt[x] = 1;
  vector<bool> mk(m);
  while (dist[dt] < l) {
    for (long long x : par)
      if (v[x] && !mk[x]) {
        wt[x] += l - dist[dt];
        mk[x] = true;
        break;
      }
    geta();
  }
  cout << "YES\n";
  for (long long i = 0; i < m; ++i)
    cout << e[i].first << " " << e[i].second << " " << wt[i] << "\n";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tc = 1;
  for (long long i = 1; i <= tc; ++i) {
    kudne();
    if (i < tc) cout << "\n";
  }
  return 0;
}
