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;
vector<pair<long long int, int> > v[1005];
long long int dist[1005];
bool vis[1005];
int parent[1005];
long long int n, m, l, s, t;
void dijk() {
  multiset<pair<long long int, int> > ms;
  ms.insert({0, s});
  while (!ms.empty()) {
    pair<long long int, int> p = *ms.begin();
    ms.erase(ms.begin());
    long long int wi = p.first, x = p.second;
    if (vis[x]) continue;
    vis[x] = true;
    for (int i = 0; i < v[x].size(); i++) {
      int fi = v[x][i].second, se = v[x][i].first;
      if (dist[x] + fi < dist[se]) {
        dist[se] = dist[x] + fi;
        ms.insert({dist[se], se});
        parent[se] = x;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> l >> s >> t;
  int x, y, w;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> w;
    v[x].push_back(make_pair(y, w));
    v[y].push_back(make_pair(x, w));
  }
  for (int i = 0; i < n; i++) dist[i] = 99999999999999;
  dist[s] = 0;
  parent[s] = -1;
  dijk();
  if (!vis[t]) {
    cout << "NO" << endl;
    return 0;
  }
  stack<pair<int, int> > st;
  int b = t, k = 0;
  while (parent[b] != -1) {
    while (k < v[parent[b]].size()) {
      if (v[parent[b]][k].second == 0 && v[parent[b]][k].first == b) {
        st.push({parent[b], k});
        break;
      }
      k++;
    }
    k = 0;
    b = parent[b];
  }
  if (st.size() + dist[t] > l) {
    while (st.size() > 0) {
      pair<int, int> p = st.top();
      v[p.first][p.second].second = 1;
      v[p.second][p.first].second = 1;
      st.pop();
    }
    memset(vis, false, sizeof vis);
    for (int i = 0; i < n; i++) {
      vis[i] = true;
      for (int j = 0; j < v[i].size(); j++) {
        if (vis[v[i][j].first])
          continue;
        else {
          if (v[i][j].second == 0) {
            v[i][j].second = 999999999;
            v[j][i].second = 999999999;
          }
        }
      }
    }
    memset(vis, false, sizeof vis);
    for (int i = 0; i <= n; i++) dist[i] = 99999999999999;
    dist[s] = 0;
    dijk();
    if (dist[t] == l) {
      memset(vis, false, sizeof vis);
      cout << "YES" << endl;
      for (int i = 0; i < n; i++) {
        vis[i] = true;
        for (int j = 0; j < v[i].size(); j++) {
          if (vis[v[i][j].first])
            continue;
          else
            cout << i << " " << v[i][j].first << " " << v[i][j].second << endl;
        }
      }
    } else {
      cout << "NO" << endl;
      return 0;
    }
  } else {
    long long int kk = l - dist[t];
    while (!st.empty()) {
      pair<int, int> p = st.top();
      if (st.size() == 1) {
        v[p.first][p.second].second = kk;
        v[p.second][p.second].second = kk;
      } else {
        v[p.first][p.second].second = 1;
        v[p.second][p.first].second = 1;
      }
      kk--;
      st.pop();
    }
    memset(vis, false, sizeof vis);
    for (int i = 0; i < n; i++) {
      vis[i] = true;
      for (int j = 0; j < v[i].size(); j++) {
        if (vis[v[i][j].first])
          continue;
        else {
          if (v[i][j].second == 0) {
            v[i][j].second = 999999999;
            v[j][i].second = 999999999;
          }
        }
      }
    }
    memset(vis, false, sizeof vis);
    for (int i = 0; i <= n; i++) dist[i] = 99999999999999;
    dist[s] = 0;
    dijk();
    if (dist[t] < l) {
      cout << "NO" << endl;
      return 0;
    }
    memset(vis, false, sizeof vis);
    cout << "YES" << endl;
    for (int i = 0; i < n; i++) {
      vis[i] = true;
      for (int j = 0; j < v[i].size(); j++) {
        if (vis[v[i][j].first])
          continue;
        else
          cout << i << " " << v[i][j].first << " " << v[i][j].second << endl;
      }
    }
  }
  return 0;
}
