7 9 999999999 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 7 9 320 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 4 5 7 0 3
0 1 0
1 2 3
2 3 0
0 2 5
1 3 5
 8 9 10 1 0
1 2 1
2 4 1
1 3 0
3 4 0
4 5 0
5 6 1
6 0 1
5 7 0
7 0 0
 4 4 14 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 5 6 1000000000 0 4
0 1 1
2 0 2
3 0 3
4 1 0
4 2 0
3 4 0
 4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
 4 4 2 1 3
1 3 13
2 3 0
2 0 0
1 0 0
 5 5 2 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 5 5 3 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 4 4 8 1 3
1 3 13
2 3 0
2 0 0
1 0 6
 1000 1 1000000000 998 0
0 999 0
 5 5 1 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 100 1 123456 99 0
0 99 123456
 4 4 13 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 7 9 319 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 1000 1 5 999 0
0 999 0

YES
0 1 1
1 2 999999996
2 3 999999997
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 YES
0 1 1
1 2 199
2 3 318
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 1 3
1 2 3
2 3 2
0 2 5
1 3 5
 YES
1 2 1
2 4 1
1 3 1
3 4 1
4 5 6
5 6 1
6 0 1
5 7 1
7 0 1
 NO YES
0 1 1
2 0 2
3 0 3
4 1 999999999
4 2 999999998
3 4 999999997
 NO NO YES
0 1 1
1 2 1
0 4 1
4 3 1
3 2 1
 NO YES
1 3 13
2 3 1
2 0 1
1 0 6
 NO NO YES
0 99 123456
 YES
1 3 13
2 3 1
2 0 1
1 0 12
 YES
0 1 1
1 2 198
2 3 317
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 999 5

#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
const int nMax = 1000 + 9;
const int mMax = 10000 + 9;
const long long OO = 1LL * 1000000000 * 1000000000 + 1;
const long long wMax = 1LL * 1000000000 * 1000000000;
int n, m, L, src, dst;
pair<pair<int, int>, long long> E[mMax];
bool is[mMax];
vector<vector<int> > G;
long long SP[nMax];
int par[nMax];
long long dijkstra() {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      PQ;
  for (int i = 0; i < n; i++) SP[i] = OO;
  memset(par, -1, sizeof par);
  SP[src] = 0;
  par[src] = -2;
  PQ.push(make_pair(0, src));
  while (!PQ.empty()) {
    pair<long long, int> top = PQ.top();
    PQ.pop();
    int u = top.second;
    long long d = top.first;
    if (d > SP[u]) continue;
    for (int i = 0, sz = G[u].size(); i < sz; i++) {
      pair<pair<int, int>, long long> e = E[G[u][i]];
      int v = e.first.first == u ? e.first.second : e.first.first;
      long long w = e.second;
      if (SP[v] <= SP[u] + w) continue;
      SP[v] = SP[u] + w;
      PQ.push(make_pair(SP[v], v));
      par[v] = G[u][i];
    }
  }
  return SP[dst];
}
void run_dijkstra(int u) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      PQ;
  PQ.push(make_pair(SP[u], u));
  while (!PQ.empty()) {
    pair<long long, int> top = PQ.top();
    PQ.pop();
    int u = top.second;
    long long d = top.first;
    if (d > SP[u]) continue;
    for (int i = 0, sz = G[u].size(); i < sz; i++) {
      pair<pair<int, int>, long long> e = E[G[u][i]];
      int v = e.first.first == u ? e.first.second : e.first.first;
      long long w = e.second;
      if (SP[v] <= SP[u] + w) continue;
      SP[v] = SP[u] + w;
      PQ.push(make_pair(SP[v], v));
    }
  }
}
int main() {
  read_file();
  while (scanf("%d%d", &n, &m) != EOF) {
    scanf("%d%d%d", &L, &src, &dst);
    memset(is, 0, sizeof is);
    G.assign(n, vector<int>());
    for (int i = 0; i < m; i++) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      E[i] = pair<pair<int, int>, long long>(make_pair(u, v), w);
      is[i] = w == 0 ? 1 : 0;
      if (!is[i]) {
        G[u].push_back(i);
        G[v].push_back(i);
      }
    }
    long long sp = dijkstra();
    if (sp < L) {
      printf("NO\n");
      continue;
    } else if (sp == L) {
      printf("YES\n");
      for (int i = 0; i < m; i++) {
        int u, v;
        long long w;
        u = E[i].first.first, v = E[i].first.second;
        w = E[i].second;
        if (w == 0) w = wMax;
        printf("%d %d %lld\n", u, v, w);
      }
      continue;
    }
    bool done = false;
    for (int i = 0; i < m; i++) {
      if (!is[i]) continue;
      int u = E[i].first.first, v = E[i].first.second;
      long long &w = E[i].second;
      if (done) {
        w = wMax;
        continue;
      }
      w = 1;
      G[u].push_back(i);
      G[v].push_back(i);
      if (llabs(SP[u] - SP[v]) <= 1) {
        continue;
      }
      if (SP[u] > SP[v]) swap(u, v);
      run_dijkstra(u);
      if (SP[dst] > L) continue;
      w += L - SP[dst];
      done = true;
    }
    if (!done) {
      printf("NO\n");
      continue;
    }
    printf("YES\n");
    for (int i = 0; i < m; i++) {
      int u, v;
      long long w;
      u = E[i].first.first, v = E[i].first.second;
      w = E[i].second;
      assert(0 <= w && w <= wMax);
      printf("%d %d %lld\n", u, v, w);
    }
  }
}
