#include <bits/stdc++.h>
using namespace ::std;
const long double PI = acos(-1);
const long long MOD = 1000000000 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long add(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a + b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long mul(long long a, long long b, long long m = MOD) {
  if (a >= m) a %= m;
  if (b >= m) b %= m;
  if (a < 0) a += m;
  if (b < 0) b += m;
  long long res = a * b;
  if (res >= m or res <= -m) res %= m;
  if (res < 0) res += m;
  return res;
}
long long pow_mod(long long a, long long b, long long m = MOD) {
  long long res = 1LL;
  a = a % m;
  while (b) {
    if (b & 1) res = mul(res, a, m);
    b >>= 1;
    a = mul(a, a, m);
  }
  return res;
}
long long fastexp(long long a, long long b) {
  long long res = 1LL;
  while (b) {
    if (b & 1) res = res * a;
    b >>= 1;
    a *= a;
  }
  return res;
}
int gcdExtendido(int a, int b, int *x, int *y) {
  if (a == 0) {
    *x = 0;
    *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtendido(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
int modInverso(int a, int m) {
  int x, y;
  int g = gcdExtendido(a, m, &x, &y);
  if (g != 1)
    return -1;
  else
    return (x % m + m) % m;
}
const long long INF = 1e14;
const int N = 1000 + 5;
const int M = 10000 + 5;
int n;
int m;
vector<int> G[N];
vector<int> E[N];
long long w[M];
int a[M];
int b[M];
vector<int> special;
long long Dijkstra(int src, int snk) {
  vector<long long> D(n, INF);
  D[src] = 0;
  priority_queue<pair<long long, int> > Q;
  Q.emplace(make_pair(0, src));
  while (!Q.empty()) {
    int u = Q.top().second;
    long long dis = -Q.top().first;
    Q.pop();
    if (D[u] < dis) continue;
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      int e = E[u][i];
      long long we = w[e];
      assert(we >= 0);
      if (!we) continue;
      if (D[v] > D[u] + we) {
        D[v] = D[u] + we;
        Q.emplace(make_pair(-D[v], v));
      }
    }
  }
  return D[snk];
}
void fixEdges(int l) {
  for (int i = 0; i < special.size(); i++) {
    if (i < l)
      w[special[i]] = 1;
    else
      w[special[i]] = INF;
  }
}
int main() {
  scanf("%d %d", &(n), &(m));
  int L, s, t;
  scanf("%d %d %d", &(L), &(s), &(t));
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &(a[i]), &(b[i]));
    scanf("%lld", &(w[i]));
    if (!w[i]) {
      special.emplace_back(i);
    }
    G[a[i]].emplace_back(b[i]);
    G[b[i]].emplace_back(a[i]);
    E[a[i]].emplace_back(i);
    E[b[i]].emplace_back(i);
  }
  if (Dijkstra(s, t) < L) {
    puts("NO");
    return 0;
  }
  for (int i : special) w[i] = 1;
  if (Dijkstra(s, t) > L) {
    puts("NO");
    return 0;
  }
  if (!special.empty()) {
    int lo = 1, hi = special.size();
    while (lo < hi) {
      int mi = lo + (hi - lo) / 2;
      fixEdges(mi);
      if (Dijkstra(s, t) > L)
        lo = mi + 1;
      else
        hi = mi;
    }
    long long low = 1, hiw = INF;
    fixEdges(lo);
    while (low < hiw) {
      long long mi = low + (hiw - low) / 2;
      w[special[lo - 1]] = mi;
      if (Dijkstra(s, t) < L)
        low = mi + 1;
      else
        hiw = mi;
    }
    w[special[lo - 1]] = low;
    assert(Dijkstra(s, t) == L);
  }
  if (Dijkstra(s, t) != L) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 0; i < m; i++) {
    printf("%d %d %lld\n", a[i], b[i], w[i]);
  }
  return 0;
}
