#include <bits/stdc++.h>
using namespace std;
long long n, m, used[20000], p[20000], c[200000], s, t, a[2000][2000],
    k[2000][2000], L, D[200000];
pair<pair<long long, long long>, long long> e[20000];
vector<long long> z, path;
long long f(int ttt) {
  for (int i = 0; i < n; i++) used[i] = 0;
  for (int i = 0; i < n; i++) c[i] = 1e17;
  for (int i = 0; i < n; i++) p[i] = 0;
  c[s] = 0;
  int v = s;
  for (int j = 0; j < n; j++) {
    long long mm = 1e16;
    used[v] = 1;
    for (int i = 0; i < n; i++)
      if (a[v][i] > 0 &&
          (c[i] > c[v] + a[v][i] || (c[i] == c[v] + a[v][i] && k[v][i]))) {
        c[i] = c[v] + a[v][i];
        p[i] = v;
      }
    for (int i = 0; i < n; i++)
      if (used[i] == 0 && c[i] < mm) {
        v = i;
        mm = c[i];
      }
  }
  if (ttt)
    for (int i = 0; i < n; i++) D[i] = c[i];
  return c[t];
}
int main() {
  cin >> n >> m >> L >> s >> t;
  for (int i = 0; i < m; i++) {
    cin >> e[i].first.first >> e[i].first.second >> e[i].second;
    a[e[i].first.first][e[i].first.second] = e[i].second;
    a[e[i].first.second][e[i].first.first] = e[i].second;
    if (e[i].second == 0) {
      z.push_back(i);
      k[e[i].first.first][e[i].first.second] = i + 1;
      k[e[i].first.second][e[i].first.first] = i + 1;
    }
  }
  for (int i = 0; i < z.size(); i++) {
    int j = z[i];
    a[e[j].first.first][e[j].first.second] = 1e14;
    a[e[j].first.second][e[j].first.first] = 1e14;
  }
  long long L2 = f(1);
  for (int i = 0; i < z.size(); i++) {
    int j = z[i];
    a[e[j].first.first][e[j].first.second] = 1;
    a[e[j].first.second][e[j].first.first] = 1;
  }
  long long L1 = f(0);
  if (L > L2 || L < L1) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < z.size(); i++) {
    int j = z[i];
    e[j].second = 1e14;
  }
  if (L2 == L) {
    cout << "YES" << endl;
    for (int i = 0; i < m; i++)
      cout << e[i].first.first << " " << e[i].first.second << " " << e[i].second
           << endl;
    return 0;
  }
  int v = t;
  while (v != s) {
    path.push_back(v);
    if (k[v][p[v]]) e[k[v][p[v]] - 1].second = 1;
    v = p[v];
  }
  path.push_back(s);
  reverse(path.begin(), path.end());
  long long s = L - c[t], r = 0;
  for (int i = 0; i < path.size() - 1; i++)
    if (k[path[i]][path[i + 1]]) {
      long long y = s;
      for (int j = i + 1; j < path.size(); j++)
        y = min(y, D[path[j]] - r - c[path[j]]);
      e[k[path[i]][path[i + 1]] - 1].second += y;
      s -= y;
      r += y;
    }
  cout << "YES" << endl;
  for (int i = 0; i < m; i++)
    cout << e[i].first.first << " " << e[i].first.second << " " << e[i].second
         << endl;
}
