#include <bits/stdc++.h>
using namespace std;
vector<int> g[2000];
long long cost[2000][2000];
bool is_special[2000][2000];
int main(void) {
  int n, m, L, s, t;
  scanf("%i %i %i %i %i", &n, &m, &L, &s, &t);
  vector<int> from(m), to(m);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%i %i %i", &u, &v, &w);
    from[i] = u;
    to[i] = v;
    is_special[u][v] = is_special[v][u] = (w == 0) ? true : false;
    if (w == 0) w++;
    g[u].push_back(v);
    g[v].push_back(u);
    cost[u][v] = cost[v][u] = w;
  }
  long long shortest_path = 1LL << 60;
  bool rep = true;
  while (rep) {
    vector<long long> dist(n);
    vector<bool> seen(n);
    vector<int> parent(n);
    for (int i = 0; i < n; i++) {
      dist[i] = 1LL << 60;
      seen[i] = false;
      parent[i] = -1;
    }
    priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                   greater<pair<long long, int> > >
        Q;
    dist[s] = 0;
    Q.push(pair<long long, int>(0, s));
    while (!Q.empty()) {
      pair<long long, int> top = Q.top();
      Q.pop();
      int u = top.second;
      if (seen[u]) continue;
      seen[u] = true;
      for (int v : g[u]) {
        long long w = cost[u][v];
        if (dist[v] > dist[u] + w) {
          dist[v] = dist[u] + w;
          parent[v] = u;
          Q.push(pair<long long, int>(dist[v], v));
        }
      }
    }
    shortest_path = dist[t];
    if (dist[t] > L) {
      puts("NO");
      return 0;
    } else if (dist[t] == L) {
      break;
    }
    rep = false;
    int cur = t;
    while (cur != s) {
      int p = parent[cur];
      if (is_special[cur][p]) {
        cost[p][cur] = cost[cur][p] += L - dist[t];
        rep = true;
        break;
      }
      cur = parent[cur];
    }
  }
  if (shortest_path == L) {
    puts("YES");
    for (int i = 0; i < m; i++) {
      printf("%i %i %lld\n", from[i], to[i], cost[from[i]][to[i]]);
    }
  } else {
    puts("NO");
  }
  return 0;
}
