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;
const int maxn = 1010;
const int maxm = 10010;
const int INF = 1e9;
const long long inf = 1e17;
struct edge {
  int u, v, w;
};
edge E[maxm];
int ans[maxn][maxn], pre[maxn];
vector<pair<int, int> > vec[maxn];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    Q;
long long dis[maxn];
bool vis[maxn];
int n, m, L, s, t;
inline void dijkstra() {
  fill(dis, dis + maxn, inf);
  memset(vis, 0, sizeof(vis));
  memset(pre, -1, sizeof(pre));
  Q.push(make_pair(dis[s] = 0, s));
  while (!Q.empty()) {
    int u = Q.top().second;
    Q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (auto &elem : vec[u]) {
      if (!vis[elem.first] && dis[elem.first] > dis[u] + elem.second) {
        pre[elem.first] = u;
        Q.push(make_pair(dis[elem.first] = dis[u] + elem.second, elem.first));
      }
    }
  }
}
inline bool check() {
  for (int i = 1; i <= n; ++i) vec[i].clear();
  for (int i = 0; i < m; ++i) {
    vec[E[i].u].emplace_back(E[i].v, E[i].w ? E[i].w : INF);
    vec[E[i].v].emplace_back(E[i].u, E[i].w ? E[i].w : INF);
  }
  dijkstra();
  if (dis[t] < L) return 0;
  for (int i = 1; i <= n; ++i) vec[i].clear();
  for (int i = 0; i < m; ++i) {
    vec[E[i].u].emplace_back(E[i].v, max(1, E[i].w));
    vec[E[i].v].emplace_back(E[i].u, max(1, E[i].w));
  }
  dijkstra();
  if (dis[t] > L) return 0;
  int l = 1, r = INF, mid, u = 0, v = 0;
  while (l < r) {
    mid = l + r >> 1;
    for (int i = 1; i <= n; ++i) vec[i].clear();
    for (int i = 0; i < m; ++i) {
      vec[E[i].u].emplace_back(E[i].v, E[i].w ? E[i].w : mid);
      vec[E[i].v].emplace_back(E[i].u, E[i].w ? E[i].w : mid);
    }
    dijkstra();
    if (dis[t] >= L)
      r = mid;
    else
      l = mid + 1;
  }
  for (int i = 1; i <= n; ++i) vec[i].clear();
  for (int i = 0; i < m; ++i) {
    vec[E[i].u].emplace_back(E[i].v, E[i].w ? E[i].w : l);
    vec[E[i].v].emplace_back(E[i].u, E[i].w ? E[i].w : l);
  }
  dijkstra();
  assert(dis[t] >= L);
  for (int i = t; i != -1; i = pre[i]) {
    if (pre[i] == -1) break;
    if (ans[pre[i]][i] == 0) {
      u = pre[i], v = i;
      break;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < i; ++j) {
      if (ans[i][j] == 0) {
        ans[i][j] = ans[j][i] = l;
      }
    }
  }
  if (u && v) {
    ans[u][v] -= dis[t] - L;
    ans[v][u] -= dis[t] - L;
  }
  return 1;
}
int main() {
  while (~scanf("%d%d%d%d%d", &n, &m, &L, &s, &t)) {
    ++s, ++t;
    memset(ans, -1, sizeof(ans));
    for (int i = 0; i < m; ++i) {
      scanf("%d%d%d", &E[i].u, &E[i].v, &E[i].w);
      ++E[i].u, ++E[i].v;
      ans[E[i].u][E[i].v] = ans[E[i].v][E[i].u] = E[i].w;
    }
    if (!check()) {
      puts("NO");
      continue;
    }
    puts("YES");
    for (int i = 0; i < m; ++i)
      printf("%d %d %d\n", E[i].u - 1, E[i].v - 1, ans[E[i].u][E[i].v]);
  }
  return 0;
}
