#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 1e4 + 5;
const int MAX = 2e6 + 5;
const int MOD = 1000000007;
int n, m, L, s, t;
vector<pair<int, int>> adj[N];
int u[N], v[N], ok[N];
long long w[N], dist[N];
void dijkstra(int src) {
  for (long long i = (1); i <= (n); ++i) dist[i] = 1e18;
  priority_queue<pair<long long, long long>> p;
  p.push({0, s});
  dist[s] = 0;
  while (!p.empty()) {
    long long d = -p.top().first;
    int x = p.top().second;
    p.pop();
    if (dist[x] < d) continue;
    for (auto it : adj[x]) {
      int y = it.first;
      int id = it.second;
      if (dist[y] > d + w[id]) {
        dist[y] = d + w[id];
        p.push({-dist[y], y});
      }
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  cout << fixed << setprecision(10);
  clock_t clk;
  clk = clock();
  ;
  cin >> n >> m >> L >> s >> t;
  ++s;
  ++t;
  for (long long i = (1); i <= (m); ++i) {
    cin >> u[i] >> v[i] >> w[i];
    u[i]++;
    v[i]++;
    if (w[i] == 0) ok[i] = 1, w[i] = 1;
    adj[u[i]].push_back({v[i], i});
    adj[v[i]].push_back({u[i], i});
  }
  dijkstra(s);
  if (dist[t] > L) {
    cout << "NO";
    return 0;
  }
  if (dist[t] == L) {
    cout << "YES\n";
    for (long long i = (1); i <= (m); ++i)
      cout << u[i] - 1 << " " << v[i] - 1 << " " << w[i] << "\n";
    return 0;
  }
  for (long long i = (1); i <= (m); ++i) {
    if (!ok[i]) continue;
    long long old = dist[t];
    w[i] = 1e15;
    dijkstra(s);
    if (dist[t] < L) continue;
    if (dist[t] > L) w[i] = L + 1 - old;
    cout << "YES\n";
    for (long long j = (1); j <= (m); ++j)
      cout << u[j] - 1 << " " << v[j] - 1 << " " << w[j] << "\n";
    return 0;
  }
  return cout << "NO", 0;
  clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk) / CLOCKS_PER_SEC
       << "\n";
  return 0;
  ;
}
