#include <bits/stdc++.h>
using namespace std;
const double E = 1e-9, pi = 2 * acos(0);
const long double PI = 3.1415926535897932384626433832795029L;
const long long INF = 1000000000000000;
vector<vector<int> > adj;
vector<int> U, V, pre;
vector<long long> W;
vector<bool> can;
long long dijkstra(int s, int t) {
  int n = (int)adj.size();
  vector<long long> dist(n, LONG_LONG_MAX);
  pre.assign(n, -1);
  dist[s] = 0;
  priority_queue<pair<long long, int> > pq;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    int u = pq.top().second;
    long long d = -pq.top().first;
    pq.pop();
    if (d > dist[u]) continue;
    for (int i = 0; i < (int)adj[u].size(); i++) {
      int e = adj[u][i], v = U[e] == u ? V[e] : U[e];
      long long w = W[e];
      if (dist[v] > d + w) {
        dist[v] = d + w;
        pq.push(make_pair(-dist[v], v));
        pre[v] = e;
      }
    }
  }
  return dist[t];
}
bool solve(int testNumber) {
  int n, m, L, s, t;
  if (scanf("%d %d %d %d %d", &n, &m, &L, &s, &t) == EOF) return false;
  adj.assign(n, vector<int>());
  U.resize(m), V.resize(m), W.resize(m), can.resize(m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %lld", &U[i], &V[i], &W[i]);
    if (!W[i]) {
      W[i] = INF;
      can[i] = true;
    } else
      can[i] = false;
    adj[U[i]].push_back(i);
    adj[V[i]].push_back(i);
  }
  bool valid = true;
  if (dijkstra(s, t) < L) valid = false;
  for (int i = 0; i < m; i++)
    if (can[i]) W[i] = 1;
  if (dijkstra(s, t) > L) valid = false;
  if (!valid)
    printf("NO\n");
  else {
    printf("YES\n");
    vector<int> used;
    for (int x = t; pre[x] != -1;) {
      int e = pre[x];
      if (can[e]) used.push_back(e);
      x = U[e] == x ? V[e] : U[e];
    }
    sort(used.begin(), used.end());
    for (int i = 0; i < m; i++)
      if (can[i] and !binary_search(used.begin(), used.end(), i)) W[i] = INF;
    while (true) {
      long long delta = L - dijkstra(s, t);
      if (!delta) break;
      for (int x = t; pre[x] != -1;) {
        int e = pre[x];
        if (can[e]) {
          W[e] += delta;
          break;
        }
        x = U[e] == x ? V[e] : U[e];
      }
    }
    for (int i = 0; i < m; i++) printf("%d %d %lld\n", U[i], V[i], W[i]);
  }
  return true;
}
void init() {}
int main() {
  init();
  for (int i = 1; solve(i); i++)
    ;
  return 0;
}
