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