#include <bits/stdc++.h>
using namespace std;
inline void prep() {
  cin.tie(0);
  cin.sync_with_stdio(0);
}
const int mod = (int)1e9 + 7;
const int MX = (int)1e3 + 5;
long long dist[MX], w[MX * 10];
vector<int> edges;
int n, m, L, s, t;
bool cirtical[MX * 10], touched[MX * 10];
int a[MX * 10], b[MX * 10];
vector<pair<int, int>> g[MX];
void dijkstra() {
  queue<int> q;
  q.push(s);
  fill(dist, dist + n, (long long)1e18);
  dist[s] = 0;
  while (not q.empty()) {
    int x = q.front();
    q.pop();
    for (auto [y, i] : g[x]) {
      if (w[i] == 0) continue;
      if (dist[x] + w[i] < dist[y]) {
        dist[y] = dist[x] + w[i];
        q.push(y);
      }
    }
  }
  if (dist[t] < L) {
    puts("NO");
    exit(0);
  }
}
void trace_back(int x) {
  for (auto [y, i] : g[x]) {
    if ((dist[x] - w[i]) == dist[y]) {
      if (cirtical[i] && !touched[i] && edges.empty()) edges.push_back(i);
      trace_back(y);
      break;
    }
  }
}
int main() {
  prep();
  cin >> n >> m >> L >> s >> t;
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i] >> w[i];
    g[a[i]].push_back({b[i], i});
    g[b[i]].push_back({a[i], i});
  }
  dijkstra();
  for (int i = 0; i < m; ++i) {
    if (w[i] == 0) {
      w[i] = 1;
      cirtical[i] = true;
    }
  }
  queue<int> q;
  do {
    q.push(s);
    memset(dist, 0x7f, sizeof dist);
    dist[s] = 0;
    while (not q.empty()) {
      int x = q.front();
      q.pop();
      for (auto [y, i] : g[x]) {
        if (dist[x] + w[i] < dist[y]) {
          dist[y] = dist[x] + w[i];
          q.push(y);
        }
      }
    }
    edges.clear();
    trace_back(t);
    int rem = L - dist[t];
    if (int(edges.size()) > 0) {
      w[edges[0]] += rem;
      touched[edges[0]] = true;
    }
  } while (dist[t] < L);
  if (dist[t] > L) return puts("NO"), 0;
  cout << "YES" << endl;
  for (int i = 0; i < m; ++i) {
    cout << a[i] << " " << b[i] << " " << w[i] << "\n";
  }
  return 0;
}
