#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1010;
const int MAXM = 100100;
const long long oo = (1ll << 50ll);
vector<pair<int, long long> > g[MAXN];
int u[MAXM];
int v[MAXM];
long long w[MAXM];
long long d1[MAXN], d2[MAXN];
long long L;
int n;
bool mk[MAXN];
void dijsktra(int ini, long long *d) {
  for (int i = 0; i <= n; i++) {
    d[i] = oo;
    mk[i] = false;
  }
  d[ini] = 0ll;
  priority_queue<pair<int, long long> > pq;
  pq.push(pair<int, long long>(0, ini));
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (mk[u]) {
      continue;
    }
    mk[u] = true;
    for (int i = 0; i < g[u].size(); i++) {
      int v = g[u][i].first;
      long long w = g[u][i].second;
      if (d[v] > d[u] + w) {
        d[v] = d[u] + w;
        pq.push(pair<int, long long>(-d[v], v));
      }
    }
  }
}
void dijsktra2(int ini, long long *d) {
  for (int i = 0; i <= n; i++) {
    d[i] = oo;
    mk[i] = false;
  }
  d[ini] = 0ll;
  priority_queue<pair<int, long long> > pq;
  pq.push(pair<int, long long>(0, ini));
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (mk[u]) {
      continue;
    }
    mk[u] = true;
    for (int i = 0; i < g[u].size(); i++) {
      int v = g[u][i].first;
      long long c = g[u][i].second;
      if (!w[c]) {
        w[c] = max(1ll, L - (d1[v] + d[u]));
      }
      if (d[v] > d[u] + w[c]) {
        d[v] = d[u] + w[c];
        pq.push(pair<int, long long>(-d[v], v));
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m, s, t;
  cin >> n >> m >> L >> s >> t;
  s++;
  t++;
  for (int i = 0; i < m; i++) {
    cin >> u[i] >> v[i] >> w[i];
    u[i]++;
    v[i]++;
    if (w[i]) {
      g[u[i]].push_back(pair<int, long long>(v[i], w[i]));
      g[v[i]].push_back(pair<int, long long>(u[i], w[i]));
    }
  }
  dijsktra(s, d1);
  for (int i = 0; i <= n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < m; i++) {
    g[u[i]].push_back(pair<int, long long>(v[i], i));
    g[v[i]].push_back(pair<int, long long>(u[i], i));
  }
  dijsktra2(t, d2);
  if (d2[s] != L) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < m; i++) {
    cout << u[i] - 1 << ' ' << v[i] - 1 << ' ' << w[i] << '\n';
  }
}
