#include <bits/stdc++.h>
using namespace std;
long long t, n, m, u, v, q, r, ql, qr, k, l, s, w, z, x, y, d, p, c, L;
const int N = 2e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 52LL;
vector<int> adj[N];
vector<pair<int, int> > f;
vector<int> cst[N];
long long dist[N];
long long sol[N];
bool vis[N];
priority_queue<pair<long long, long long> > Q;
void dijkstra() {
  for (int i = 0; i < n; ++i) dist[i] = 1e10, vis[i] = false;
  ;
  Q = priority_queue<pair<long long, long long> >();
  dist[s] = 0;
  Q.push(make_pair(0, s));
  while (!Q.empty()) {
    int v = Q.top().second;
    Q.pop();
    if (vis[v]) continue;
    vis[v] = true;
    for (int i = 0; i < adj[v].size(); ++i) {
      int u = adj[v][i];
      if (dist[u] > dist[v] + cst[v][i]) {
        dist[u] = dist[v] + cst[v][i];
        Q.push(make_pair(-dist[u], u));
      }
    }
  }
}
int to[N], from[N];
long long cosst[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> L >> s >> t;
  for (int i = 0; i < N; ++i) sol[i] = 1e10;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v >> c;
    to[i] = u;
    from[i] = v;
    cosst[i] = c;
    if (c != 0) {
      adj[u].push_back(v);
      adj[v].push_back(u);
      cst[u].push_back(c);
      cst[v].push_back(c);
    }
    if (c == 0) {
      f.push_back(make_pair(u, v));
    }
  }
  dijkstra();
  long long ans = dist[t];
  if (ans < L) {
    cout << "NO\n";
    return 0;
  }
  if (ans == L) {
    cout << "YES\n";
    for (int i = 0; i < m; ++i) {
      if (cosst[i] != 0)
        cout << to[i] << " " << from[i] << " " << cosst[i] << '\n';
    }
    for (int i = 0; i < f.size(); ++i)
      cout << f[i].first << " " << f[i].second << " " << sol[i] << '\n';
    return 0;
  }
  bool valid = false;
  for (int i = 0; i < f.size(); ++i) {
    adj[f[i].first].push_back(f[i].second);
    adj[f[i].second].push_back(f[i].first);
    cst[f[i].first].push_back(1);
    cst[f[i].second].push_back(1);
    dijkstra();
    sol[i] = 1;
    long long new_ans = dist[t];
    ans = new_ans;
    if (new_ans > L)
      continue;
    else {
      sol[i] = L - new_ans + 1;
      new_ans = L;
      ans = L;
      break;
    }
  }
  if (ans > L)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < m; ++i) {
      if (cosst[i] != 0)
        cout << to[i] << " " << from[i] << " " << cosst[i] << '\n';
    }
    for (int i = 0; i < f.size(); ++i)
      cout << f[i].first << " " << f[i].second << " " << sol[i] << '\n';
    return 0;
  }
  return 0;
}
