#include <bits/stdc++.h>
using namespace std;
int d[1005], x[10005], y[10005], z[10005], g[1005][1005], n, m, e, s, t;
bool v[1005];
int work(int w, int p) {
  int i, j;
  for (i = 1; i <= p; i++) {
    if (!z[i]) g[x[i]][y[i]] = g[y[i]][x[i]] = w + 1;
  }
  for (i = p + 1; i <= m; i++) {
    if (!z[i]) g[x[i]][y[i]] = g[y[i]][x[i]] = w;
  }
  for (i = 0; i < n; i++) d[i] = 1000000002;
  d[s] = 0;
  memset(v, false, sizeof(v));
  for (i = 1; i < n; i++) {
    int t = 1000000002, k;
    for (j = 0; j < n; j++) {
      if ((!v[j]) && d[j] < t) {
        t = d[j];
        k = j;
      }
    }
    v[k] = 1;
    for (j = 0; j < n; j++) {
      if (g[k][j] != -1) d[j] = min(d[j], d[k] + g[k][j]);
    }
  }
  return d[t];
}
int main() {
  int i, j;
  scanf("%d%d%d%d%d", &n, &m, &e, &s, &t);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) g[i][j] = -1;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &x[i], &y[i], &z[i]);
    g[x[i]][y[i]] = g[y[i]][x[i]] = z[i];
  }
  if (work(1000000002, 0) < e) {
    puts("NO");
    return 0;
  }
  if (work(1, 0) > e) {
    puts("NO");
    return 0;
  }
  puts("YES");
  int L = 1, R = 1000000002;
  while (L <= R) {
    int M = (L + R) >> 1;
    if (work(M, 0) <= e)
      L = M + 1;
    else
      R = M - 1;
  }
  int T = 1, W = m;
  while (T <= W) {
    int M = (T + W) >> 1;
    if (work(R, M) <= e)
      T = M + 1;
    else
      W = M - 1;
  }
  for (i = 1; i <= W; i++) {
    if (!z[i]) z[i] = L;
  }
  for (i = W + 1; i <= m; i++) {
    if (!z[i]) z[i] = R;
  }
  for (i = 1; i <= m; i++) printf("%d %d %d\n", x[i], y[i], z[i]);
  return 0;
}
