#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u, v, sp;
  long long c;
  int getV(int u) { return u == this->u ? this->v : this->u; }
};
vector<Edge> V;
vector<vector<int> > adj;
long long ditra(int s, int t) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      PQ;
  PQ.push(pair<long long, int>(0, s));
  vector<long long> D(adj.size(), 1000000000000000000LL);
  D[s] = 0;
  while (PQ.size()) {
    pair<long long, int> c = PQ.top();
    PQ.pop();
    long long u = c.second, d = c.first;
    if (D[u] < d) continue;
    if (u == t) return d;
    for (int e : adj[u]) {
      Edge &ed = V[e];
      long long v = ed.getV(u), nd = d + ed.c;
      if (D[v] > nd) {
        D[v] = nd;
        PQ.push(pair<long long, int>(nd, v));
      }
    }
  }
  return 1000000000000000000LL;
}
int main() {
  int N, M, s, t;
  long long L;
  cin >> N >> M >> L >> s >> t;
  adj = vector<vector<int> >(N);
  for (int i = 0; i < M; ++i) {
    Edge e;
    cin >> e.u >> e.v >> e.c;
    if (e.c == 0)
      e.sp = 1, e.c = 1;
    else
      e.sp = 0;
    V.push_back(e);
    adj[e.u].push_back(i);
    adj[e.v].push_back(i);
  }
  if (ditra(s, t) < L)
    for (Edge &e : V) {
      if (e.sp == 0) continue;
      e.c = 1000000000;
      if (ditra(s, t) < L) continue;
      int lo = 1, hi = 1000000000;
      while (lo < hi) {
        int mi = (lo + hi + 1) / 2;
        e.c = mi;
        long long d = ditra(s, t);
        if (d <= L) {
          lo = mi;
        } else {
          hi = mi - 1;
        }
      }
      e.c = lo;
      break;
    }
  if (ditra(s, t) == L) {
    cout << "YES" << endl;
    for (Edge &e : V) {
      cout << e.u << " " << e.v << " " << e.c << endl;
    }
  } else {
    cout << "NO" << endl;
  }
}
