#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while ('0' > s || '9' < s) {
    if (s == '-') f = -1;
    s = getchar();
  }
  while ('0' <= s && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
int n, m, L, s, t, head[20005], tot, dis[20005], dis1[20005];
bool vis[20005];
struct edge {
  int from, to, nxt, paid;
  bool flag;
} e[20005 << 1];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
void addEdge(int u, int v, int w, bool f) {
  e[++tot] = (edge){u, v, head[u], w + f, f};
  head[u] = tot;
}
void dijkstra() {
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n; i++) dis[i] = INF;
  while (!q.empty()) q.pop();
  q.push(make_pair(0, s));
  dis[s] = 0;
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].to, w = e[i].paid;
      if (dis[u] + w < dis[v])
        dis[v] = dis[u] + w, q.push(make_pair(dis[v], v));
    }
  }
}
signed main() {
  read(n);
  read(m);
  read(L);
  read(s);
  read(t);
  tot = 1;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    read(u);
    read(v);
    read(w);
    addEdge(u, v, w, !w);
    addEdge(v, u, w, !w);
  }
  dijkstra();
  if (dis[t] > L) {
    puts("NO");
    return 0;
  }
  memset(vis, 0, sizeof(vis));
  int L1 = L - dis[t];
  for (int i = 0; i < n; i++) dis1[i] = dis[i], dis[i] = INF;
  while (!q.empty()) q.pop();
  q.push(make_pair(0, s));
  dis[s] = 0;
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].to;
      if (e[i].flag && dis[u] + e[i].paid < dis1[v] + L1)
        e[i].paid = e[i ^ 1].paid = dis1[v] + L1 - dis[u];
      if (dis[u] + e[i].paid < dis[v])
        dis[v] = dis[u] + e[i].paid, q.push(make_pair(dis[v], v));
    }
  }
  if (dis[t] != L) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 2; i <= tot; i += 2)
    printf("%d %d %d\n", e[i].from, e[i].to, e[i].paid);
  return 0;
}
