#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 1024, M = 10240;
int u0[M], v0[M], c0[M];
bool flag[2 * M];
int first[N], dis[N], pre[N], nxt[2 * M], vv[2 * M], c[2 * M], tot;
inline void add(int u, int v, int cost) {
  vv[tot] = v;
  c[tot] = cost;
  nxt[tot] = first[u];
  first[u] = tot++;
}
int spfa(int s, int t) {
  memset(dis, 0x3f, sizeof dis);
  dis[s] = 0;
  pre[s] = -1;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = first[u]; ~i; i = nxt[i]) {
      int v = vv[i];
      if (dis[v] > dis[u] + c[i]) {
        dis[v] = dis[u] + c[i];
        pre[v] = i;
        q.push(v);
      }
    }
  }
  return dis[t];
}
int main() {
  int n, m, l, s, t;
  cin >> n >> m >> l >> s >> t;
  memset(first, -1, sizeof first);
  tot = 0;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", u0 + i, v0 + i, c0 + i);
    if (c0[i]) {
      add(u0[i], v0[i], c0[i]);
      add(v0[i], u0[i], c0[i]);
    }
  }
  if (spfa(s, t) < l) {
    puts("NO");
    return 0;
  }
  memset(first, -1, sizeof first);
  tot = 0;
  for (int i = 0; i < m; ++i) {
    if (c0[i]) {
      add(u0[i], v0[i], c0[i]);
      add(v0[i], u0[i], c0[i]);
    } else {
      flag[tot] = true;
      add(u0[i], v0[i], 1);
      flag[tot] = true;
      add(v0[i], u0[i], 1);
    }
  }
  if (spfa(s, t) > l) {
    puts("NO");
    return 0;
  }
  puts("YES");
  while (spfa(s, t) < l) {
    int _ = t;
    while (!flag[pre[_]]) _ = vv[pre[_] ^ 1];
    c[pre[_] ^ 1] = c[pre[_]] += l - dis[t];
  }
  for (int i = 0; i < m; ++i) c0[i] = c[i * 2];
  for (int i = 0; i < m; ++i) printf("%d %d %d\n", u0[i], v0[i], c0[i]);
  return 0;
}
