#include <bits/stdc++.h>
using namespace std;
int N, M, S, T;
vector<pair<int, int>> adj[1100], e;
bool un[10100];
long long L, cost[1100], value[10100];
bool inq[1100];
queue<int> q;
long long go() {
  for (int i = (0); i < (N); i++) cost[i] = 1e18;
  cost[S] = 0, q.push(S), inq[S] = 1;
  while (q.size()) {
    int i = q.front();
    q.pop();
    inq[i] = 0;
    for (auto j : adj[i])
      if (cost[j.first] > cost[i] + value[j.second]) {
        cost[j.first] = cost[i] + value[j.second];
        if (!inq[j.first]) q.push(j.first), inq[j.first] = 1;
      }
  }
  return cost[T];
}
int main() {
  scanf("%d %d %lld %d %d", &N, &M, &L, &S, &T);
  for (int i = (0); i < (M); i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    e.push_back(make_pair(a, b));
    value[i] = c;
    adj[a].push_back(make_pair(b, i));
    adj[b].push_back(make_pair(a, i));
    if (!c) un[i] = 1;
  }
  for (int i = (0); i < (M); i++)
    if (un[i]) {
      value[i] = 1;
    }
  long long best = go();
  for (int i = (0); i < (M); i++)
    if (un[i]) {
      value[i] = 2e9;
    }
  long long worst = go();
  if (L < best || L > worst) return puts("NO"), 0;
  puts("YES");
  if (worst > L) {
    for (int i = (0); i < (M); i++)
      if (un[i]) {
        value[i] = 1;
        long long g = go();
        if (g <= L) {
          value[i] = 1 + (L - g);
          break;
        }
      }
  }
  assert(go() == L);
  for (int i = (0); i < (M); i++) {
    int a, b;
    tie(a, b) = e[i];
    printf("%d %d %lld\n", a, b, value[i]);
  }
  return 0;
}
