#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
inline void in() {}
template <class T, class... Ts>
inline void in(T& x, Ts&... xs) {
  int c, s = 0;
  x = 0;
  while (c = getchar(), c != '-' && (c < '0' || c > '9'))
    ;
  if (c == '-') s = 1, c = getchar();
  do x = x * 10 + (c - '0');
  while (c = getchar(), c >= '0' && c <= '9');
  if (s) x = -x;
  in(xs...);
}
inline void ins(char* s) {
  char c;
  while (c = getchar(), c < 33)
    ;
  do *s++ = c;
  while (c = getchar(), c > 32);
  *s = 0;
}
const int INF = 1e9 + 1;
int n, m, l, s, t;
vector<pair<int, int>> g[1000];
set<pair<int, int>> eds;
int d[1000];
int p[1000];
int dijk() {
  for (int i = 0; i < n; i++) d[i] = INF + 1;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pq.push({0, s});
  while (!pq.empty()) {
    int x = pq.top().second, v = pq.top().first;
    pq.pop();
    if (d[x] != INF + 1) continue;
    d[x] = v;
    for (auto e : g[x]) {
      if (d[e.first] == INF + 1) pq.push({min(INF, v + e.second), e.first});
    }
  }
  return d[t];
}
int dijk2() {
  for (int i = 0; i < n; i++) d[i] = INF + 1;
  priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int>>,
                 greater<pair<pair<int, int>, int>>>
      pq;
  pq.push({{0, s}, -1});
  while (!pq.empty()) {
    int x = pq.top().first.second, v = pq.top().first.first,
        pp = pq.top().second;
    pq.pop();
    if (d[x] != INF + 1) continue;
    d[x] = v;
    p[x] = pp;
    for (auto e : g[x]) {
      if (d[e.first] == INF + 1)
        pq.push({{min(INF, v + e.second), e.first}, x});
    }
  }
  return d[t];
}
void modify(pair<int, int> e, int v) {
  *lower_bound(g[e.first].begin(), g[e.first].end(), make_pair(e.second, 0)) = {
      e.second, v};
  *lower_bound(g[e.second].begin(), g[e.second].end(),
               make_pair(e.first, 0)) = {e.first, v};
}
int main() {
  in(n, m, l, s, t);
  for (int i = 0; i < m; i++) {
    int a, b, w;
    in(a, b, w);
    if (w == 0) eds.insert({a, b}), eds.insert({b, a}), w = INF;
    g[a].push_back({b, w});
    g[b].push_back({a, w});
  }
  for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end());
  int mx = dijk();
  if (mx < l) printf("NO\n"), exit(0);
  for (auto e : eds) {
    modify(e, 1);
  }
  int cur = dijk2();
  if (cur > l) printf("NO\n"), exit(0);
  set<pair<int, int>> bad;
  int x = t;
  while (x != s) {
    if (eds.count({x, p[x]}) > 0) bad.insert({x, p[x]});
    x = p[x];
  }
  for (auto e : eds) {
    if (bad.count(e) == 0 && bad.count({e.second, e.first}) == 0)
      modify(e, INF);
  }
  while (cur < l) {
    pair<int, int> e = *bad.begin();
    bad.erase(bad.begin());
    modify(e, INF);
    int nxt = dijk();
    if (nxt >= l) {
      modify(e, l - cur + 1);
      break;
    }
    cur = nxt;
  }
  printf("YES\n");
  set<pair<int, int>> seen;
  for (int i = 0; i < n; i++) {
    for (auto j : g[i]) {
      if (seen.count({i, j.first}) == 0) {
        seen.insert({j.first, i});
        printf("%d %d %d\n", i, j.first, j.second);
      }
    }
  }
}
