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;
using ii = pair<long long int, long long int>;
const long long int N = 1000 + 5, INF = 1e18, M = 10000 + 5;
vector<long long int> G[N];
vector<ii> g[N];
long long int dist[N][N], d1[N], d2[N], U[M], V[M], W[M], p[N];
long long int n, m, s, t, L;
void djk() {
  priority_queue<ii, vector<ii>, greater<ii> > q;
  q.push({0, s});
  d1[s] = 0;
  while (!q.empty()) {
    long long int u = q.top().second, d = q.top().first;
    q.pop();
    for (auto& it : g[u]) {
      long long int v = it.first, w = it.second;
      if (d + w < d1[v]) {
        d1[v] = d + w;
        q.push({d1[v], v});
      }
    }
  }
}
bool djk2() {
  priority_queue<ii, vector<ii>, greater<ii> > q;
  q.push({0, s});
  d2[s] = 0;
  while (!q.empty()) {
    long long int u = q.top().second, d = q.top().first;
    q.pop();
    for (long long int v : G[u]) {
      long long int w = dist[u][v];
      if (d + abs(w) < d2[v]) {
        d2[v] = d + abs(w);
        p[v] = u;
        q.push({d2[v], v});
      }
    }
  }
  if (d2[t] > L) {
    return false;
  }
  long long int cur = t;
  while (cur != s) {
    long long int par = p[cur];
    if (dist[cur][par] < 0) {
      dist[par][cur] = dist[cur][par] = -2;
    }
    cur = p[cur];
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      if (dist[i][j] == -1) {
        dist[i][j] = INF;
      }
    }
  }
  cur = t;
  while (cur != s) {
    long long int par = p[cur];
    if (dist[cur][par] < 0) {
      dist[par][cur] = dist[cur][par] = -1;
    }
    cur = p[cur];
  }
  return true;
}
bool relax() {
  for (long long int i = 0; i < n; i++) {
    d2[i] = INF;
  }
  priority_queue<ii, vector<ii>, greater<ii> > q;
  q.push({0, s});
  d2[s] = 0;
  while (!q.empty()) {
    long long int u = q.top().second, d = q.top().first;
    q.pop();
    for (auto& v : G[u]) {
      long long int w = dist[u][v];
      if (d + abs(w) < d2[v]) {
        d2[v] = d + abs(w);
        p[v] = u;
        q.push({d2[v], v});
      }
    }
  }
  if (d2[t] == L) {
    return true;
  }
  long long int cur = t;
  bool check = false;
  while (cur != s) {
    long long int par = p[cur];
    if (dist[cur][par] < 0 and !check) {
      dist[cur][par] = dist[par][cur] = abs(dist[par][cur]) + L - d2[t];
      check = true;
    }
    if (check) {
      break;
    }
    cur = p[cur];
  }
  return false;
}
int32_t main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m >> L >> s >> t;
  for (long long int i = 0; i <= n; i++) {
    d1[i] = d2[i] = INF;
  }
  for (long long int i = 0, u, v; i < m; i++) {
    cin >> u >> v >> W[i];
    U[i] = u, V[i] = v;
    if (W[i] != 0) {
      g[u].push_back({v, W[i]});
      g[v].push_back({u, W[i]});
      G[u].push_back(v);
      G[v].push_back(u);
      dist[u][v] = dist[v][u] = W[i];
    } else {
      G[u].push_back(v);
      G[v].push_back(u);
      dist[u][v] = dist[v][u] = -1;
    }
  }
  djk();
  if (d1[t] < L) {
    cout << "NO\n";
    return 0;
  }
  if (d1[t] == L) {
    cout << "YES\n";
    for (long long int i = 0; i < m; i++) {
      cout << U[i] << " " << V[i] << " ";
      cout << ((W[i] == 0) ? INF : W[i]) << "\n";
    }
    return 0;
  }
  if (!djk2()) {
    cout << "NO\n";
    return 0;
  }
  while (!relax()) {
    relax();
  }
  cout << "YES\n";
  for (long long int i = 0; i < m; i++) {
    cout << U[i] << " " << V[i] << " " << abs(dist[U[i]][V[i]]) << "\n";
  }
  return 0;
}
