#include <bits/stdc++.h>
const int N = 1005;
using namespace std;
long long n, m, L, s, t;
vector<int> g[N];
bool can[N][N];
long long d[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m >> L >> s >> t;
  while (m--) {
    long long u, v, c;
    cin >> u >> v >> c;
    g[u].push_back(v);
    g[v].push_back(u);
    if (c == 0) {
      d[u][v] = d[v][u] = 1;
      can[u][v] = can[v][u] = 1;
    } else {
      d[u][v] = d[v][u] = c;
    }
  }
  while (true) {
    vector<long long> dist(N, LLONG_MAX), par(N, 0);
    dist[s] = 0;
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long>>,
                   greater<pair<long long, long long>>>
        pq;
    pq.push({0, s});
    while (!pq.empty()) {
      int u = pq.top().second;
      pq.pop();
      for (auto v : g[u]) {
        if (dist[u] + d[u][v] < dist[v]) {
          dist[v] = dist[u] + d[u][v];
          par[v] = u;
          pq.push({dist[v], v});
        }
      }
    }
    if (dist[t] > L) {
      cout << "NO" << endl;
      return 0;
    }
    if (dist[t] == L) {
      cout << "YES" << endl;
      for (int i = 0; i <= n; i++) {
        for (auto j : g[i]) {
          if (i < j) cout << i << ' ' << j << ' ' << d[i][j] << '\n';
        }
      }
      return 0;
    }
    long long lef = L - dist[t];
    int cur = t;
    bool done = 0;
    while (cur != s) {
      int pr = par[cur];
      if (can[pr][cur]) {
        can[pr][cur] = can[cur][pr] = 0;
        d[pr][cur] += lef;
        d[cur][pr] += lef;
        done = 1;
        break;
      }
      cur = pr;
    }
    if (!done) {
      cout << "NO" << endl;
      return 0;
    }
  }
  return 0;
}
