7 9 999999999 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 7 9 320 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 4 5 7 0 3
0 1 0
1 2 3
2 3 0
0 2 5
1 3 5
 8 9 10 1 0
1 2 1
2 4 1
1 3 0
3 4 0
4 5 0
5 6 1
6 0 1
5 7 0
7 0 0
 4 4 14 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 5 6 1000000000 0 4
0 1 1
2 0 2
3 0 3
4 1 0
4 2 0
3 4 0
 4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
 4 4 2 1 3
1 3 13
2 3 0
2 0 0
1 0 0
 5 5 2 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 5 5 3 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 4 4 8 1 3
1 3 13
2 3 0
2 0 0
1 0 6
 1000 1 1000000000 998 0
0 999 0
 5 5 1 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 100 1 123456 99 0
0 99 123456
 4 4 13 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 7 9 319 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 1000 1 5 999 0
0 999 0

YES
0 1 1
1 2 999999996
2 3 999999997
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 YES
0 1 1
1 2 199
2 3 318
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 1 3
1 2 3
2 3 2
0 2 5
1 3 5
 YES
1 2 1
2 4 1
1 3 1
3 4 1
4 5 6
5 6 1
6 0 1
5 7 1
7 0 1
 NO YES
0 1 1
2 0 2
3 0 3
4 1 999999999
4 2 999999998
3 4 999999997
 NO NO YES
0 1 1
1 2 1
0 4 1
4 3 1
3 2 1
 NO YES
1 3 13
2 3 1
2 0 1
1 0 6
 NO NO YES
0 99 123456
 YES
1 3 13
2 3 1
2 0 1
1 0 12
 YES
0 1 1
1 2 198
2 3 317
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 999 5

#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, L, beg, end;
  cin >> n >> m >> L >> beg >> end;
  vector<vector<pair<int, long long>>> g(n);
  vector<int> deleted(m);
  vector<array<pair<int, int>, 2>> where(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    long long w;
    cin >> a >> b >> w;
    if (w == 0) {
      deleted[i] = 1;
      w = inf;
    }
    where[i][0] = make_pair(a, g[a].size());
    where[i][1] = make_pair(b, g[b].size());
    g[a].emplace_back(b, w);
    g[b].emplace_back(a, w);
  }
  auto Dijkstra = [&]() {
    set<pair<long long, int>> s;
    vector<long long> d(n, inf);
    d[beg] = 0;
    for (int i = 0; i < n; i++) {
      s.insert(make_pair(d[i], i));
    }
    while (!s.empty()) {
      int v = s.begin()->second;
      s.erase(s.begin());
      for (const auto& [u, w] : g[v]) {
        if (d[v] + w < d[u]) {
          s.erase(make_pair(d[u], u));
          d[u] = d[v] + w;
          s.insert(make_pair(d[u], u));
        }
      }
    }
    return d[end];
  };
  if (Dijkstra() < L) {
    cout << "NO" << '\n';
    exit(0);
  }
  for (int v = 0; v < n; v++) {
    for (auto& [u, w] : g[v]) {
      if (w == inf) {
        w = 1;
      }
    }
  }
  if (Dijkstra() > L) {
    cout << "NO" << '\n';
    exit(0);
  }
  for (int i = 0; i < m; i++) {
    if (!deleted[i]) {
      continue;
    }
    long long low = 1, high = inf, mid;
    while (low < high) {
      mid = (low + high + 1) >> 1;
      g[where[i][0].first][where[i][0].second].second = mid;
      g[where[i][1].first][where[i][1].second].second = mid;
      if (Dijkstra() <= L) {
        low = mid;
      } else {
        high = mid - 1;
      }
    }
    g[where[i][0].first][where[i][0].second].second = low;
    g[where[i][1].first][where[i][1].second].second = low;
    if (Dijkstra() == L) {
      cout << "YES" << '\n';
      for (int j = 0; j < m; j++) {
        assert(g[where[j][0].first][where[j][0].second].second ==
               g[where[j][1].first][where[j][1].second].second);
        cout << where[j][0].first << ' ' << where[j][1].first << ' '
             << g[where[j][0].first][where[j][0].second].second << '\n';
      }
      exit(0);
    }
  }
  cout << "NO" << '\n';
  return 0;
}
