#include <bits/stdc++.h>
using namespace std;
bool scan(int& x) { return scanf("%d", &x) == 1; }
bool scan(long long& x) { return scanf("%I64d", &x) == 1; }
bool scan(char* s) { return scanf("%s", s) == 1; }
template <typename T, typename... TT>
bool scan(T& x, TT&... xx) {
  return scan(x) && scan(xx...);
}
const int N = 1010;
vector<int> g[N];
int n, m, L, s, t;
int u[N * N], v[N * N];
long long w[N * N];
long long dis1[N], dis2[N];
int id[N];
bool vis[N];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
int main() {
  while (scan(n, m, L, s, t)) {
    for (int i = 0; i < (n); ++i) g[i].clear();
    for (int i = 0; i < (m); ++i) {
      scan(u[i], v[i], w[i]);
      g[u[i]].push_back(i);
      g[v[i]].push_back(i);
    }
    memset(dis1, 0x3f, sizeof dis1);
    memset(vis, 0, sizeof vis);
    while (q.size()) q.pop();
    dis1[t] = 0;
    q.push(pair<long long, int>(0, t));
    while (!q.empty()) {
      int now = q.top().second;
      if (now == s) break;
      q.pop();
      if (vis[now]) continue;
      vis[now] = true;
      for (unsigned i = 0; i < g[now].size(); ++i) {
        int e = g[now][i], nxt = now ^ u[e] ^ v[e];
        if (w[e] == 0) continue;
        if (dis1[now] + w[e] < dis1[nxt]) {
          dis1[nxt] = dis1[now] + w[e];
          q.push(pair<long long, int>(dis1[nxt], nxt));
        }
      }
    }
    if (dis1[s] < L) {
      puts("NO");
      continue;
    }
    memset(dis2, 0x3f, sizeof dis2);
    memset(vis, 0, sizeof vis);
    while (q.size()) q.pop();
    dis2[s] = 0;
    q.push(pair<long long, int>(0, s));
    while (!q.empty()) {
      int now = q.top().second;
      q.pop();
      if (vis[now]) continue;
      vis[now] = true;
      for (unsigned i = 0; i < g[now].size(); ++i) {
        int e = g[now][i], nxt = now ^ u[e] ^ v[e];
        if (w[e] == 0) {
          w[e] = max(1LL, L - dis2[now] - dis1[nxt]);
        }
        if (dis2[now] + w[e] < dis2[nxt]) {
          dis2[nxt] = dis2[now] + w[e];
          q.push(pair<long long, int>(dis2[nxt], nxt));
        }
      }
    }
    if (dis2[t] != L) {
      puts("NO");
      continue;
    }
    puts("YES");
    for (int i = 0; i < (m); ++i) printf("%d %d %I64d\n", u[i], v[i], w[i]);
  }
  return 0;
}
