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;
long long n, m, L, start, endP;
vector<vector<long long> > edges;
vector<vector<long long> > neighbors;
vector<vector<long long> > paths;
long long weights[1000][1000] = {0};
long long dijk() {
  vector<long long> distances(n, LLONG_MAX);
  distances[start] = 0;
  vector<bool> visited(n, false);
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push({0, start});
  while (!pq.empty()) {
    long long currentWeight = pq.top().first;
    long long currentNode = pq.top().second;
    pq.pop();
    if (visited[currentNode]) continue;
    visited[currentNode] = true;
    if (currentNode == endP) break;
    for (long long i = 0; i < neighbors[currentNode].size(); i++) {
      long long currNeighbor = neighbors[currentNode][i];
      long long currDist = weights[currentNode][currNeighbor];
      if (currDist == -1) continue;
      if (currentWeight + currDist < distances[currNeighbor])
        distances[currNeighbor] = currentWeight + currDist;
      if (!visited[currNeighbor])
        pq.push({distances[currNeighbor], currNeighbor});
    }
  }
  return distances[endP];
}
long long dijk2() {
  vector<long long> distances(n, LLONG_MAX);
  distances[start] = 0;
  vector<bool> visited(n, false);
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push({0, start});
  paths[0].push_back(0);
  while (!pq.empty()) {
    long long currentWeight = pq.top().first;
    long long currentNode = pq.top().second;
    pq.pop();
    if (visited[currentNode]) continue;
    visited[currentNode] = true;
    if (currentNode == endP) break;
    for (long long i = 0; i < neighbors[currentNode].size(); i++) {
      long long currNeighbor = neighbors[currentNode][i];
      long long currDist = weights[currentNode][currNeighbor];
      if (currDist == -1) currDist = 1;
      if (currentWeight + currDist < distances[currNeighbor]) {
        distances[currNeighbor] = currentWeight + currDist;
        paths[currNeighbor] = paths[currentNode];
        paths[currNeighbor].push_back(currNeighbor);
      }
      if (!visited[currNeighbor])
        pq.push({distances[currNeighbor], currNeighbor});
    }
  }
  return distances[endP];
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> L >> start >> endP;
  edges.resize(m);
  neighbors.resize(n);
  paths.resize(n);
  long long from, to, weight;
  for (long long i = 0; i < m; i++) {
    cin >> from >> to >> weight;
    if (weight == 0) weight = -1;
    weights[from][to] = weight;
    weights[to][from] = weight;
    edges[i] = {from, to, weight};
    neighbors[from].push_back(to);
    neighbors[to].push_back(from);
  }
  long long currMin = dijk();
  if (currMin < L) {
    cout << "NO" << endl;
    return 0;
  }
  long long newMin = dijk2();
  long long diff = L - newMin;
  pair<long long, long long> last;
  for (long long i = 1; i < paths[endP].size(); i++) {
    long long prev = paths[endP][i - 1];
    long long curr = paths[endP][i];
    if (weights[prev][curr] == -1) {
      weights[prev][curr] = 1;
      weights[curr][prev] = 1;
      last = {prev, curr};
    }
  }
  if (diff < 0) {
    cout << "NO" << endl;
    return 0;
  } else {
    weights[last.first][last.second] += diff;
    weights[last.second][last.first] += diff;
  }
  cout << "YES" << endl;
  for (long long i = 0; i < edges.size(); i++) {
    long long from = edges[i][0];
    long long to = edges[i][1];
    long long weight = weights[from][to];
    if (weight == -1) weight = 999999999999;
    cout << from << ' ' << to << ' ' << weight << endl;
  }
  return 0;
}
