#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const int maxm = 10010;
int n, m, L, S, T, cnt, diff;
int head[maxn], u[maxm], v[maxm], w[maxm], dis[maxn], diss[maxn];
bool check[maxm], vis[maxn];
struct edge {
  int to, nxt, id;
} e[maxm << 1];
inline int read() {
  char c = getchar();
  int res = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res * f;
}
inline void add(int u, int v, int id) {
  e[++cnt].nxt = head[u];
  head[u] = cnt;
  e[cnt].to = v;
  e[cnt].id = id;
}
inline void spfa1() {
  memset(dis, 0x3f, sizeof(dis));
  queue<int> q;
  q.push(S);
  dis[S] = 0;
  vis[S] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    vis[x] = 0;
    for (int i = head[x]; i; i = e[i].nxt) {
      int y = e[i].to;
      if (dis[y] > dis[x] + w[e[i].id]) {
        dis[y] = dis[x] + w[e[i].id];
        if (!vis[y]) vis[y] = 1, q.push(y);
      }
    }
  }
}
inline void spfa2() {
  memset(diss, 0x3f, sizeof(diss));
  queue<int> q;
  diss[S] = 0;
  q.push(S);
  vis[S] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    vis[x] = 0;
    for (int i = head[x]; i; i = e[i].nxt) {
      int y = e[i].to;
      if (check[e[i].id] && dis[y] + diff > diss[x] + w[e[i].id])
        w[e[i].id] = dis[y] + diff - diss[x];
      if (diss[y] > diss[x] + w[e[i].id]) {
        diss[y] = diss[x] + w[e[i].id];
        if (!vis[y]) vis[y] = 1, q.push(y);
      }
    }
  }
}
int main() {
  n = read(), m = read();
  L = read(), S = read(), T = read();
  for (int i = 1; i <= m; i++) {
    u[i] = read(), v[i] = read(), w[i] = read();
    if (!w[i]) w[i] = 1, check[i] = 1;
    add(u[i], v[i], i);
    add(v[i], u[i], i);
  }
  spfa1();
  if (dis[T] > L) {
    puts("NO");
    return 0;
  }
  diff = L - dis[T];
  spfa2();
  if (diss[T] != L) {
    puts("NO");
    return 0;
  } else {
    puts("YES");
    for (int i = 1; i <= m; i++) printf("%d %d %d\n", u[i], v[i], w[i]);
  }
  return 0;
}
