#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 1e6 + 5;
const long long INF = 1e12 + 5;
int n, m, s, t;
long long l;
pair<pair<int, int>, long long> edg[10005];
long long d[1005];
int par[1005];
bool vis[1005];
int mark[10005];
vector<int> g[1005];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
long long dijkstra() {
  fill_n(d, n, INF);
  fill_n(vis, n, 0);
  d[s] = 0;
  par[s] = -1;
  q.push(make_pair(0, s));
  int u, v, i;
  long long w;
  while (!q.empty()) {
    v = q.top().second;
    q.pop();
    if (vis[v]) {
      continue;
    }
    vis[v] = true;
    for (i = 0; i < g[v].size(); ++i) {
      u = (v ^ edg[g[v][i]].first.first ^ edg[g[v][i]].first.second);
      w = edg[g[v][i]].second;
      if (d[u] > d[v] + w) {
        d[u] = d[v] + w;
        par[u] = g[v][i];
        q.push(make_pair(d[u], u));
      }
    }
  }
  return d[t];
}
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%lld", &l);
  scanf("%d%d", &s, &t);
  for (i = 0; i < m; ++i) {
    scanf("%d%d%lld", &edg[i].first.first, &edg[i].first.second,
          &edg[i].second);
    if (edg[i].second) {
      g[edg[i].first.first].push_back(i);
      g[edg[i].first.second].push_back(i);
    } else {
      mark[i] = 1;
    }
  }
  if (dijkstra() < l) {
    printf("NO\n");
  } else {
    for (i = 0; i < m; ++i) {
      if (mark[i] == 1) {
        edg[i].second = 1;
        g[edg[i].first.first].push_back(i);
        g[edg[i].first.second].push_back(i);
      }
    }
    if (dijkstra() > l) {
      printf("NO\n");
    } else {
      for (j = t, i = par[j]; i != -1;) {
        if (mark[i] == 1) {
          mark[i] = 2;
        }
        j = (j ^ edg[i].first.first ^ edg[i].first.second);
        i = par[j];
      }
      for (i = 0; i < m; ++i) {
        if (mark[i] == 1) {
          edg[i].second = INF;
        }
      }
      while (dijkstra() < l) {
        for (j = t, i = par[j]; i != -1;) {
          if (mark[i] == 2) {
            mark[i] = 3;
            edg[i].second += l - d[t];
            break;
          }
          j = (j ^ edg[i].first.first ^ edg[i].first.second);
          i = par[j];
        }
      }
      printf("YES\n");
      for (i = 0; i < m; ++i) {
        printf("%d %d %lld\n", edg[i].first.first, edg[i].first.second,
               edg[i].second);
      }
    }
  }
  return 0;
}
