#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > g_alap[1001];
vector<pair<long long, long long> > g_uj[1001];
vector<pair<long long, long long> > meghatarozatlanok;
vector<pair<long long, pair<long long, long long> > > simak;
long long n, m, L, t, s;
long long ismeretlen_el_szam = 0;
struct lehetoseg {
  long long cel, tav;
  lehetoseg(long long becel, long long betav) {
    cel = becel;
    tav = betav;
  }
  bool operator<(const lehetoseg& masik) const { return tav > masik.tav; }
};
long long s_to_t(long long uj_el_eddig) {
  vector<long long> tav(n, -1);
  priority_queue<lehetoseg> sor;
  sor.push(lehetoseg(s, 0));
  while (sor.size()) {
    auto akt = sor.top();
    sor.pop();
    if (tav[akt.cel] != -1) continue;
    tav[akt.cel] = akt.tav;
    for (auto el : g_alap[akt.cel]) {
      sor.push(lehetoseg(el.first, akt.tav + el.second));
    }
    for (auto el : g_uj[akt.cel]) {
      if (el.second <= uj_el_eddig) {
        sor.push(lehetoseg(el.first, akt.tav + 1));
      }
    }
  }
  return tav[t] == -1 ? 1000000000000000000L : tav[t];
}
int main() {
  cin >> n >> m >> L >> s >> t;
  for (long long i = 1; i <= m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    if (w == 0) {
      ismeretlen_el_szam++;
      g_uj[u].push_back(make_pair(v, ismeretlen_el_szam));
      g_uj[v].push_back(make_pair(u, ismeretlen_el_szam));
      meghatarozatlanok.push_back(make_pair(u, v));
    } else {
      g_alap[u].push_back(make_pair(v, w));
      g_alap[v].push_back(make_pair(u, w));
      simak.push_back(make_pair(w, make_pair(u, v)));
    }
  }
  if (s_to_t(0) < L || s_to_t(ismeretlen_el_szam) > L) {
    cout << "NO";
    return 0;
  }
  long long k = 0, v = ismeretlen_el_szam;
  while (k < v) {
    long long kozep = (k + v) / 2;
    if (s_to_t(kozep) > L)
      k = kozep + 1;
    else if (s_to_t(kozep - 1) > L)
      k = v = kozep;
    else
      v = kozep - 1;
  }
  long long mennyipluszkell = L - s_to_t(k) + 1;
  cout << "YES" << endl;
  for (auto el : simak) {
    cout << el.second.first << " " << el.second.second << " " << el.first
         << endl;
  }
  for (long long i = 0; i < meghatarozatlanok.size(); i++) {
    long long index = i + 1;
    cout << meghatarozatlanok[i].first << " " << meghatarozatlanok[i].second
         << " ";
    if (index < k)
      cout << 1 << endl;
    else if (index == k)
      cout << mennyipluszkell << endl;
    else
      cout << 1000000000000000000L << endl;
  }
}
