#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const string task = "rvq";
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int n, m, s, t;
vector<pair<long long, long long> > adj[10005];
vector<int> todo;
long long v[10005], u[10005], w[10005], d[10005], L;
void dijkstra() {
  for (int i = int(0); i <= int(n); i++) d[i] = (1ll << 60);
  d[s] = 0ll;
  priority_queue<pair<long long, long long> > pq;
  pq.push({0, s});
  while (!pq.empty()) {
    long long x = pq.top().second;
    long long tt = -pq.top().first;
    pq.pop();
    if (d[x] < tt) continue;
    for (auto i : adj[x]) {
      if (d[i.first] > d[x] + i.second) {
        d[i.first] = d[x] + i.second;
        pq.push({-d[i.first], i.first});
      }
    }
  }
}
long long check(long long x) {
  for (auto i : todo) {
    w[i] = 1 + min(x, 1000000000LL);
    x -= w[i] - 1;
  }
  for (int i = int(0); i <= int(n); i++) adj[i].clear();
  for (int i = int(1); i <= int(m); i++) {
    adj[v[i]].push_back({u[i], w[i]});
    adj[u[i]].push_back({v[i], w[i]});
  }
  dijkstra();
  return d[t];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> L >> s >> t;
  for (int i = int(1); i <= int(m); i++) {
    cin >> v[i] >> u[i] >> w[i];
    if (w[i] == 0) todo.push_back(i);
  }
  long long l = 0, d = 1000000000LL * todo.size(), mid, ans = -1;
  if (check(0) > L || check(d) < L) {
    cout << "NO\n";
    return 0;
  }
  while (l <= d) {
    mid = (l + d) / 2ll;
    if (check(mid) <= L) {
      ans = mid;
      l = mid + 1;
    } else
      d = mid - 1;
  }
  check(ans);
  cout << "YES\n";
  for (int i = int(1); i <= int(m); i++) {
    cout << v[i] << ' ' << u[i] << ' ' << w[i] << '\n';
  }
  return 0;
}
