#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 20, M = 1e4 + 20;
const long long int OO = 1e15;
long long int n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve() {
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int> >,
                 greater<pair<long long int, long long int> > >
      pq;
  memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
  pq.push(pair<long long int, long long int>(0, t));
  while (pq.size()) {
    long long int dist = pq.top().first, u = pq.top().second;
    pq.pop();
    if (~bestTS[u]) continue;
    bestTS[u] = dist;
    for (int i = 0; i < n; i++)
      if (adj[u][i] > 0)
        pq.push(pair<long long int, long long int>(dist + adj[u][i], i));
  }
  while (pq.size()) pq.pop();
  pq.push(pair<long long int, long long int>(0, s));
  while (pq.size()) {
    long long int dist = pq.top().first, u = pq.top().second;
    pq.pop();
    if (~bestST[u]) continue;
    bestST[u] = dist;
    for (int i = 0; i < n; i++) {
      if (adj[u][i] > 0)
        pq.push(pair<long long int, long long int>(dist + adj[u][i], i));
      else if (adj[u][i] == 0 && bestTS[i] != -1 && l - dist - bestTS[i] > 0) {
        adj[u][i] = adj[i][u] = l - dist - bestTS[i];
      } else if (adj[u][i] == 0)
        adj[u][i] = adj[i][u] = 1;
      if (~adj[u][i])
        pq.push(pair<long long int, long long int>(dist + adj[u][i], i));
    }
  }
  memset(bestST, -1, sizeof bestST);
  pq.push(pair<long long int, long long int>(0, s));
  while (pq.size()) {
    long long int dist = pq.top().first, u = pq.top().second;
    pq.pop();
    if (~bestST[u]) continue;
    bestST[u] = dist;
    for (int i = 0; i < n; i++)
      if (adj[u][i] >= 0)
        pq.push(pair<long long int, long long int>(dist + adj[u][i], i));
  }
  if (bestST[t] != l) {
    cout << "NO\n";
    return;
  } else {
    cout << "YES\n";
    for (int i = 0; i < m; i++) {
      W[i] = adj[U[i]][V[i]];
      cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
    }
  }
}
int main() {
  cin >> n >> m >> l >> s >> t;
  memset(adj, -1, sizeof adj);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    U[i] = u, V[i] = v, W[i] = w;
    adj[u][v] = adj[v][u] = w;
  }
  solve();
  return 0;
}
