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 = 1e3 + 3;
vector<int> G[MAXN];
int n, m, l;
long long d[MAXN];
int father[MAXN];
int vis[MAXN][MAXN], cost[MAXN][MAXN], valid[MAXN][MAXN], cam[MAXN][MAXN];
int s, t;
long long dijk() {
  priority_queue<pair<int, int> > pq;
  pq.push({0, s});
  d[s] = 0;
  father[s] = -1;
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (u == t) return d[u];
    for (auto v : G[u]) {
      int c = cost[u][v];
      if (!c) continue;
      if (d[v] == -1 || d[v] > d[u] + c) {
        d[v] = d[u] + c;
        father[v] = u;
        pq.push({-d[v], v});
      }
    }
  }
  return l + 1;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d %d", &l, &s, &t);
  for (int i = (int)0; i < (int)m; i++) {
    int u, v, w;
    scanf("%d %d", &u, &v);
    scanf("%d", &w);
    G[u].push_back(v);
    G[v].push_back(u);
    cost[u][v] = w;
    cost[v][u] = w;
  }
  memset(d, -1, sizeof(d));
  int ans = dijk();
  if (ans < l) {
    printf("NO\n");
    return 0;
  }
  for (int u = (int)0; u < (int)n; u++) {
    for (int j = (int)0; j < (int)G[u].size(); j++) {
      int v = G[u][j];
      if (cost[u][v] == 0) cost[u][v] = 1, valid[u][v] = 1;
    }
  }
  memset(d, -1, sizeof(d));
  int ans1 = dijk();
  if (ans1 > l) {
    printf("NO\n");
    return 0;
  }
  vector<pair<int, int> > vec;
  int curr = t;
  while (curr != -1) {
    int v = father[curr];
    if (valid[curr][v])
      cam[curr][v] = 1, cam[v][curr] = 1, vec.push_back({curr, v});
    curr = v;
  }
  for (int u = (int)0; u < (int)n; u++)
    for (int v = (int)0; v < (int)n; v++)
      if (valid[u][v] && !cam[u][v]) cost[u][v] = l + 1;
  int p = 0;
  ans = ans1;
  while (p < vec.size()) {
    int u = vec[p].first, v = vec[p].second;
    int lo = 0, hi = l;
    while (lo < hi) {
      int mid = (lo + hi + 1) / 2;
      memset(d, -1, sizeof(d));
      cost[u][v] += mid;
      cost[v][u] += mid;
      long long curr = dijk();
      if (curr == l) {
        cost[u][v] -= mid;
        cost[v][u] -= mid;
        lo = mid;
        break;
      } else if (curr != ans + mid || curr > l)
        hi = mid - 1;
      else
        lo = mid;
      cost[u][v] -= mid;
      cost[v][u] -= mid;
    }
    cost[u][v] += lo;
    cost[v][u] += lo;
    p++;
    memset(d, -1, sizeof(d));
    ans = dijk();
    if (ans == l) break;
  }
  printf("YES\n");
  for (int u = (int)0; u < (int)n; u++) {
    for (auto v : G[u]) {
      if (vis[u][v]) continue;
      vis[u][v] = 1;
      vis[v][u] = 1;
      int w = cost[u][v];
      printf("%d %d %d\n", u, v, w);
    }
  }
}
