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;
struct comp {
  bool operator()(pair<long long, long long> a, pair<long long, long long> b) {
    return a.second > b.second;
  }
};
vector<pair<long long, long long> > g[1001];
long long D[1001];
long long D2[1001];
pair<pair<long long, long long>, long long> edge[100001];
long long P[1001], Pa[1001];
vector<long long> v;
long long visited[1001], visited2[1001];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               comp>
    pq;
map<pair<long long, long long>, long long> m;
void djkstra(long long s) {
  D[s] = 0;
  P[s] = -1;
  pq.push(make_pair(s, D[s]));
  long long i, j, k;
  long long u, v;
  while (!pq.empty()) {
    pair<long long, long long> a = pq.top();
    pq.pop();
    long long u = a.first;
    if (visited[u]) continue;
    visited[u] = 1;
    for (i = 0; i < g[u].size(); i++) {
      long long v = g[u][i].first;
      long long w = g[u][i].second;
      if (!visited[v] && D[u] + w < D[v]) {
        D[v] = D[u] + w;
        P[v] = u;
        pq.push(make_pair(v, D[v]));
      }
    }
  }
}
void djkstra2(long long s) {
  D2[s] = 0;
  Pa[s] = -1;
  pq.push(make_pair(s, D2[s]));
  long long i, j, k;
  long long u, v;
  while (!pq.empty()) {
    pair<long long, long long> a = pq.top();
    pq.pop();
    long long u = a.first;
    if (visited2[u]) continue;
    visited2[u] = 1;
    for (i = 0; i < g[u].size(); i++) {
      long long v = g[u][i].first;
      long long w = g[u][i].second;
      if (w == 0) continue;
      if (!visited2[v] && D2[u] + w < D2[v]) {
        D2[v] = D2[u] + w;
        Pa[v] = u;
        pq.push(make_pair(v, D2[v]));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long N, C, i, j, k, T;
  long long M;
  long long s, t, L;
  cin >> N >> M >> L >> s >> t;
  for (i = 0; i < N; i++) {
    visited[i] = 0;
    D[i] = 1e18;
    D2[i] = 1e18;
    visited2[i] = 0;
  }
  for (i = 0; i < M; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
    edge[i].first.first = u;
    edge[i].first.second = v;
    edge[i].second = w;
    m[make_pair(u, v)] = i;
    m[make_pair(v, u)] = i;
  }
  djkstra2(s);
  if (D2[t] < L) {
    cout << "NO" << endl;
    return 0;
  }
  djkstra(s);
  if (D[t] == 1e18) {
    cout << "NO" << endl;
    return 0;
  }
  i = t;
  long long p;
  long long lastchild;
  long long lastpar;
  while (P[i] != -1) {
    p = P[i];
    if (edge[m.find(make_pair(i, p))->second].second == 0) {
      v.push_back(m.find(make_pair(p, i))->second);
      edge[m.find(make_pair(p, i))->second].second = 1;
      lastchild = i;
      lastpar = p;
    }
    i = p;
  }
  if (L - D[t] - v.size() < 0 || (v.size() == 0 && L != D[t])) {
    cout << "NO" << endl;
    return 0;
  }
  edge[m.find(make_pair(lastchild, lastpar))->second].second +=
      L - D[t] - v.size();
  cout << "YES" << endl;
  long long res = L - D[t] - v.size();
  long long status = 0;
  long long taken[100001];
  for (i = 0; i < M; i++) taken[i] = 0;
  i = t;
  for (i = 0; i < M; i++) {
    if (edge[i].second == 0) edge[i].second = 1;
  }
  for (i = 0; i < M; i++) {
    cout << edge[i].first.first << " " << edge[i].first.second << " "
         << edge[i].second << endl;
  }
}
