#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct edge {
  int v, w, next;
} e[10005 << 1];
int head[1005], k;
inline void add(int u, int v, int w) {
  e[k] = (edge){v, w, head[u]};
  head[u] = k++;
}
int n, m, dis[1005], s, t, L;
bool vis[1005], is[10005 << 1];
inline void dijkstra() {
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  dis[s] = 0;
  q.push(make_pair(dis[s], s));
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (register int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].v;
      if (dis[u] + e[i].w < dis[v]) {
        dis[v] = dis[u] + e[i].w;
        q.push(make_pair(dis[v], v));
      }
    }
  }
}
inline void print() {
  puts("YES");
  for (register int i = 0; i < k; i += 2)
    printf("%d %d %d\n", e[i ^ 1].v - 1, e[i].v - 1, e[i].w);
}
int diss[1005], diff;
inline void dijkstra1() {
  memset(diss, 0x3f, sizeof(diss));
  memset(vis, 0, sizeof(vis));
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  diss[s] = 0;
  q.push(make_pair(diss[s], s));
  while (!q.empty()) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].v;
      if (is[i] && dis[v] + diff > diss[u] + e[i].w)
        e[i].w = e[i ^ 1].w = dis[v] + diff - diss[u];
      if (diss[u] + e[i].w < diss[v]) {
        diss[v] = diss[u] + e[i].w;
        q.push(make_pair(diss[v], v));
      }
    }
  }
  if (diss[t] == L)
    print();
  else
    puts("NO");
}
int main() {
  n = read(), m = read(), L = read(), s = read() + 1, t = read() + 1;
  memset(head, -1, sizeof(head));
  for (register int i = 1; i <= m; ++i) {
    int u = read() + 1, v = read() + 1, w = read();
    if (!w) w = 1, is[k] = is[k + 1] = true;
    add(u, v, w);
    add(v, u, w);
  }
  dijkstra();
  diff = L - dis[t];
  if (dis[t] == L)
    print();
  else if (dis[t] > L)
    puts("NO");
  else
    dijkstra1();
  return 0;
}
