#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.);
const int N = 1e3 + 5;
const int M = 1e4 + 5;
const int INF = 0x7f7f7f7f;
struct edge {
  int v, w;
};
long long n, m, L, s, t;
vector<edge> G[N];
int u[M], v[M], w[M];
long long d[N];
void addedge(int u, int v, int w) {
  G[u].push_back((edge){v, w});
  G[v].push_back((edge){u, w});
}
void dij(int s) {
  memset(d, INF, sizeof(d));
  d[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    pair<int, int> pii = pq.top();
    pq.pop();
    int u = pii.second, dist = pii.first;
    if (d[u] < dist) continue;
    int sz = G[u].size();
    for (int i = 0; i < sz; i++) {
      edge& e = G[u][i];
      int v = e.v;
      if (d[v] > d[u] + e.w) {
        d[v] = d[u] + e.w;
        pq.push(make_pair(d[v], v));
      }
    }
  }
}
int main() {
  while (cin >> n >> m >> L >> s >> t) {
    for (int i = 0; i <= n; i++) G[i].clear();
    for (int i = 0; i < m; i++) {
      cin >> u[i] >> v[i] >> w[i];
      if (w[i] != 0) {
        addedge(u[i], v[i], w[i]);
      }
    }
    dij(s);
    int pos = -1;
    if (d[t] < L) {
      puts("NO");
      continue;
    } else if (d[t] == L) {
      puts("YES");
      for (int i = 0; i < m; i++) {
        if (w[i] != 0)
          printf("%d %d %d\n", u[i], v[i], w[i]);
        else
          printf("%d %d %d\n", u[i], v[i], INF);
      }
    } else if (d[t] > L) {
      for (int i = 0; i < m; i++) {
        if (w[i]) continue;
        addedge(u[i], v[i], 1);
        dij(s);
        if (d[t] > L) continue;
        pos = i;
        break;
      }
      if (pos == -1) {
        puts("NO");
        continue;
      }
      puts("YES");
      for (int i = 0; i < pos; i++) {
        if (w[i])
          printf("%d %d %d\n", u[i], v[i], w[i]);
        else
          printf("%d %d %d\n", u[i], v[i], 1);
      }
      printf("%d %d %d\n", u[pos], v[pos], L - d[t] + 1);
      for (int i = pos + 1; i < m; i++) {
        if (w[i])
          printf("%d %d %d\n", u[i], v[i], w[i]);
        else
          printf("%d %d %d\n", u[i], v[i], INF);
      }
    }
  }
  return 0;
}
