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<pair<long long, long long>, long long> > vf;
vector<pair<long long, long long> > adj[1008];
vector<int> num[1008];
long long n;
long long m;
long long l;
long long s, t;
long long st[10008], nd[10008], val[10008];
int var[10008] = {0};
long long vis[1008] = {0};
void dfs(long long u) {
  if (vis[u]) return;
  vis[u] = 1;
  long long sz = adj[u].size();
  for (int j = 0; j < sz; j++) {
    pair<long long, long long> v = adj[u][j];
    dfs((long long)v.first);
  }
}
int main() {
  scanf("%lld", &n);
  scanf("%lld", &m);
  scanf("%lld", &l);
  scanf("%lld", &s);
  scanf("%lld", &t);
  for (long long i = 0; i < m; i++) {
    long long u, v;
    long long w;
    scanf("%lld", &u);
    scanf("%lld", &v);
    scanf("%lld", &w);
    st[i] = u;
    nd[i] = v;
    val[i] = w;
    if (!w) var[i] = 1;
    adj[u].push_back(pair<long long, long long>(v, w));
    num[u].push_back(i);
    adj[v].push_back(pair<long long, long long>(u, w));
    num[v].push_back(i);
  }
  dfs(s);
  if (!vis[t]) {
    cout << "NO";
    return 0;
  }
  vector<long long> dist;
  dist.resize(1008, 1000000000000000000ll);
  dist[s] = 0;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push(pair<long long, long long>(0, s));
  while (!pq.empty()) {
    pair<long long, long long> front = pq.top();
    pq.pop();
    long long d = front.first, u = front.second;
    if (d > dist[u]) continue;
    for (long long j = 0; j < (long long)adj[u].size(); j++) {
      pair<long long, long long> v = adj[u][j];
      long long ex = 1000000000000000000ll;
      if (v.second == 0)
        ;
      else
        ex = v.second;
      if (dist[u] + ex < dist[v.first]) {
        dist[v.first] = dist[u] + ex;
        pq.push(pair<long long, long long>(dist[v.first], v.first));
      }
    }
  }
  if (dist[t] < l) {
    cout << "NO";
    return 0;
  } else if (dist[t] == l) {
    printf("YES\n");
    for (long long i = 0; i < m; i++) {
      long long ex = (val[i] ? val[i] : 1000000000000000000ll);
      printf("%llu %llu %llu\n", st[i], nd[i], ex);
    }
    return 0;
  }
  while (!pq.empty()) pq.pop();
  dist.clear();
  dist.resize(1008, 1000000000000000000ll);
  dist[t] = 0;
  pq.push(pair<long long, long long>(0, t));
  while (!pq.empty()) {
    pair<long long, long long> front = pq.top();
    pq.pop();
    long long d = front.first, u = front.second;
    if (d > dist[u]) continue;
    for (long long j = 0; j < (long long)adj[u].size(); j++) {
      pair<long long, long long> v = adj[u][j];
      long long ex = max(v.second, 1ll);
      if (dist[u] + ex < dist[v.first]) {
        dist[v.first] = dist[u] + ex;
        pq.push(pair<long long, long long>(dist[v.first], v.first));
      }
    }
  }
  if (dist[s] > l) {
    cout << "NO";
    return 0;
  }
  while (!pq.empty()) pq.pop();
  vector<int> diss(1008, 1000000007);
  diss[s] = 0;
  pq.push(pair<long long, long long>(0, s));
  while (!pq.empty()) {
    pair<long long, long long> front = pq.top();
    pq.pop();
    long long d = front.first, u = front.second;
    if (d > diss[u]) continue;
    for (long long j = 0; j < (long long)adj[u].size(); j++) {
      pair<long long, long long> v = adj[u][j];
      if (var[num[u][j]]) {
        val[num[u][j]] = v.second =
            max(val[num[u][j]], max(1ll, l - dist[v.first] - diss[u]));
      }
      long long ex = v.second;
      if (diss[u] + ex < diss[v.first]) {
        diss[v.first] = diss[u] + ex;
        pq.push(pair<long long, long long>(diss[v.first], v.first));
      }
    }
  }
  printf("YES");
  printf("\n");
  for (int i = 0; i < m; i++) {
    printf("%llu %llu %llu\n", st[i], nd[i], (val[i] ? val[i] : l));
  }
}
