#include <bits/stdc++.h>
using namespace std;
using ii = pair<long long int, long long int>;
const long long int N = 1000 + 5, INF = 1e18, M = 10000 + 5;
vector<long long int> G[N];
vector<ii> g[N];
long long int dist[N][N], d1[N], d2[N], U[M], V[M], W[M], p[N];
long long int n, m, s, t, L;
void djk() {
  priority_queue<ii, vector<ii>, greater<ii> > q;
  q.push({0, s});
  d1[s] = 0;
  while (!q.empty()) {
    long long int u = q.top().second;
    q.pop();
    for (auto& it : g[u]) {
      long long int v = it.first, w = it.second;
      if (d1[u] + w < d1[v]) {
        d1[v] = d1[u] + w;
        q.push({d1[v], v});
      }
    }
  }
}
bool djk2() {
  priority_queue<ii, vector<ii>, greater<ii> > q;
  q.push({0, s});
  d2[s] = 0;
  while (!q.empty()) {
    long long int u = q.top().second;
    q.pop();
    for (long long int v : G[u]) {
      long long int w = dist[u][v];
      if (d2[u] + abs(w) < d2[v]) {
        d2[v] = d2[u] + abs(w);
        p[v] = u;
        q.push({d2[v], v});
      }
    }
  }
  if (d2[t] > L) {
    return false;
  }
  long long int cur = t;
  while (cur != s) {
    long long int par = p[cur];
    if (dist[cur][par] < 0) {
      dist[par][cur] = dist[cur][par] = -2;
    }
    cur = p[cur];
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (dist[i][j] == -1) {
        dist[i][j] = INF;
      }
    }
  }
  cur = t;
  while (cur != s) {
    long long int par = p[cur];
    if (dist[cur][par] < 0) {
      dist[par][cur] = dist[cur][par] = -1;
    }
    cur = p[cur];
  }
  return true;
}
bool relax() {
  for (long long int i = 0; i < n; i++) {
    d2[i] = INF;
  }
  priority_queue<ii, vector<ii>, greater<ii> > q;
  q.push({0, s});
  d2[s] = 0;
  while (!q.empty()) {
    long long int u = q.top().second;
    q.pop();
    for (auto& v : G[u]) {
      long long int w = dist[u][v];
      if (d2[u] + abs(w) < d2[v]) {
        d2[v] = d2[u] + abs(w);
        p[v] = u;
        q.push({d2[v], v});
      }
    }
  }
  if (d2[t] == L) {
    return true;
  }
  long long int cur = t;
  while (cur != s) {
    long long int par = p[cur];
    if (dist[cur][par] < 0) {
      dist[cur][par] = dist[par][cur] = abs(dist[par][cur]) + L - d2[t];
      break;
    }
    cur = p[cur];
  }
  return false;
}
int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m >> L >> s >> t;
  for (long long int i = 0; i <= n; i++) {
    d1[i] = d2[i] = INF;
  }
  for (long long int i = 0, u, v; i < m; i++) {
    cin >> u >> v >> W[i];
    U[i] = u, V[i] = v;
    if (W[i] != 0) {
      g[u].push_back({v, W[i]});
      g[v].push_back({u, W[i]});
      G[u].push_back(v);
      G[v].push_back(u);
      dist[u][v] = dist[v][u] = W[i];
    } else {
      G[u].push_back(v);
      G[v].push_back(u);
      dist[u][v] = dist[v][u] = -1;
    }
  }
  djk();
  if (d1[t] < L) {
    cout << "NO\n";
    return 0;
  }
  if (d1[t] == L) {
    cout << "YES\n";
    for (long long int i = 0; i < m; i++) {
      cout << U[i] << " " << V[i] << " ";
      cout << ((W[i] == 0) ? INF : W[i]) << "\n";
    }
    return 0;
  }
  if (!djk2()) {
    cout << "NO\n";
    return 0;
  }
  while (!relax()) {
    relax();
  }
  cout << "YES\n";
  for (long long int i = 0; i < m; i++) {
    cout << U[i] << " " << V[i] << " " << abs(dist[U[i]][V[i]]) << "\n";
  }
  return 0;
}
