#include <bits/stdc++.h>
namespace IO {
inline char gc() {
  static const int Rlen = 1 << 22 | 1;
  static char buf[Rlen], *p1, *p2;
  return (p1 == p2) && (p2 = (p1 = buf) + fread(buf, 1, Rlen, stdin)) ? EOF
                                                                      : *p1++;
}
template <typename T>
inline T get() {
  char c;
  T num;
  while (!isdigit(c = gc()))
    ;
  num = c ^ 48;
  while (isdigit(c = gc())) num = (num + (num << 2) << 1) + (c ^ 48);
  return num;
}
inline int gi() { return get<int>(); }
}  // namespace IO
using namespace IO;
using std::cerr;
using std::cout;
using pli = std::pair<long long, int>;
const int N = 1e3 + 7, M = 2e4 + 7;
int n, m, L, S, T;
int el[N], nxt[M], to[M];
long long w[M], ec = 1;
inline void adde(int u, int v, int val) {
  nxt[++ec] = el[u], el[u] = ec, to[ec] = v, w[ec] = val;
  nxt[++ec] = el[v], el[v] = ec, to[ec] = u, w[ec] = val;
}
bool modi[M], inq[N], vis[N];
long long disT[N], disS[N];
std::set<pli> s;
signed main() {
  n = gi(), m = gi(), L = gi(), S = gi(), T = gi();
  for (int register i = 1; i <= m; ++i) {
    int u = gi(), v = gi(), w = gi();
    if (!w) modi[i] = true, w = 1;
    adde(u, v, w);
  }
  memset(disT, 0x3f, sizeof disT);
  s.insert(pli(disT[T] = 0, T));
  while (!s.empty()) {
    int u = s.begin()->second;
    s.erase(s.begin());
    for (int register e = el[u], v = to[e]; e; v = to[e = nxt[e]])
      if (disT[v] > disT[u] + w[e]) {
        if (inq[v]) s.erase(pli(disT[v], v));
        disT[v] = disT[u] + w[e];
        inq[v] = true;
        s.insert(pli(disT[v], v));
      }
  }
  memset(disS, 0x3f, sizeof disS);
  memset(inq, 0, sizeof inq);
  s.insert(pli(disS[S] = 0, S));
  inq[S] = true;
  while (!s.empty()) {
    int u = s.begin()->second;
    s.erase(s.begin());
    vis[u] = true;
    for (int register e = el[u], v = to[e]; e; v = to[e = nxt[e]])
      if (!vis[v]) {
        if (modi[e >> 1])
          w[e] = w[e ^ 1] = std::max(1ll, L - disS[u] - disT[v]);
        if (disS[v] > disS[u] + w[e]) {
          if (inq[v]) s.erase(pli(disS[v], v));
          disS[v] = disS[u] + w[e];
          inq[v] = true;
          s.insert(pli(disS[v], v));
        }
      }
  }
  if (disS[T] != L)
    puts("No");
  else {
    puts("Yes");
    for (int register i = 1; i <= m; ++i)
      cout << to[i << 1 | 1] << " " << to[i << 1] << " " << w[i << 1] << "\n";
  }
  return 0;
}
