#include <bits/stdc++.h>
using namespace std;
const int maxn = 10005;
int u[maxn], v[maxn], w[maxn], flag[maxn], vis[maxn], n, m, L, s, t, need;
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    Q;
vector<pair<int, int> > e[maxn];
long long dis[maxn], dis2[maxn];
void dijkstra(int f, long long d[maxn]) {
  memset(d, 0x3f, sizeof dis);
  memset(vis, 0, sizeof vis);
  int u = s;
  d[s] = 0;
  Q.push(make_pair(0, s));
  while (!Q.empty()) {
    u = Q.top().second;
    Q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (auto k : e[u]) {
      if (f && flag[k.second] && dis2[u] + w[k.second] < dis[k.first] + need)
        w[k.second] = dis[k.first] + need - dis2[u];
      if (d[u] + w[k.second] < d[k.first]) {
        d[k.first] = d[u] + w[k.second];
        Q.push(make_pair(d[k.first], k.first));
      }
    }
  }
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &L, &s, &t);
  s++;
  t++;
  for (int i = (1); i <= int(m); i++) {
    scanf("%d%d%d", &u[i], &v[i], &w[i]);
    if (!w[i]) flag[i] = w[i] = 1;
    e[u[i] + 1].push_back(make_pair(v[i] + 1, i));
    e[v[i] + 1].push_back(make_pair(u[i] + 1, i));
  }
  dijkstra(0, dis);
  if (dis[t] > L) return puts("NO"), 0;
  need = L - dis[t];
  dijkstra(1, dis2);
  if (dis2[t] != L) return puts("NO"), 0;
  puts("YES");
  for (int i = (1); i <= int(m); i++) printf("%d %d %d\n", u[i], v[i], w[i]);
  return 0;
}
