#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1111, MMAX = 11111;
int N, M, L, S, T;
int U[MMAX], V[MMAX];
long long W[MMAX];
bool targets[MMAX];
long long dp[NMAX];
int back[NMAX];
vector<int> g[NMAX];
const long long LINF = 1e18, INF = 1e10;
void dijkstra() {
  for (int i = 0; i < N; i++) back[i] = -1;
  for (int i = 0; i < N; i++) dp[i] = LINF;
  dp[S] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      pq;
  pq.push({0LL, S});
  while (!pq.empty()) {
    pair<long long, int> t = pq.top();
    pq.pop();
    long long cost = t.first;
    int here = t.second;
    if (cost <= dp[here]) {
      for (int e : g[here]) {
        int there = U[e] + V[e] - here;
        long long ncost = cost + W[e];
        if (ncost < dp[there]) {
          dp[there] = ncost;
          back[there] = e;
          pq.push({ncost, there});
        }
      }
    }
  }
}
int main() {
  scanf("%d%d%d%d%d", &N, &M, &L, &S, &T);
  for (int i = 0; i < M; i++) {
    scanf("%d%d%lld", U + i, V + i, W + i);
    g[U[i]].push_back(i);
    g[V[i]].push_back(i);
    if (W[i] == 0) targets[i] = true;
  }
  for (int i = 0; i < M; i++)
    if (targets[i]) W[i] = INF;
  dijkstra();
  if (dp[T] < L) {
    return !printf("NO");
  } else if (dp[T] == L) {
    printf("YES\n");
    for (int i = 0; i < M; i++) printf("%d %d %lld\n", U[i], V[i], W[i]);
    return 0;
  }
  for (int i = 0; i < M; i++)
    if (targets[i]) W[i] = 1;
  dijkstra();
  if (dp[T] > L) {
    return !printf("NO");
  }
  vector<int> path;
  int it = T;
  while (it != S) {
    int e = back[it];
    if (e == -1) break;
    if (targets[e]) path.push_back(e);
    it = U[e] + V[e] - it;
  }
  for (int i = 0; i < M; i++)
    if (targets[i]) W[i] = INF;
  for (int p : path) W[p] = 1;
  dijkstra();
  for (int p : path) {
    W[p] += L - dp[T];
    dijkstra();
    if (dp[T] == L) {
      printf("YES\n");
      for (int i = 0; i < M; i++) printf("%d %d %lld\n", U[i], V[i], W[i]);
      return 0;
    }
  }
  printf("NO");
}
