#include <bits/stdc++.h>
using namespace std;
int n, m, L, s, t, u[20005], v[20005];
long long ow[20005], w[20005];
vector<int> G[1005];
long long d[1005];
long long dijkstra() {
  for (int i = 0; i < n; i++) d[i] = 1LL << 50;
  priority_queue<pair<long long, int> > q;
  d[s] = 0;
  q.push({0, s});
  while (!q.empty()) {
    pair<long long, int> t = q.top();
    q.pop();
    for (int j : G[t.second]) {
      if (-t.first + w[j] < d[v[j]]) {
        d[v[j]] = -t.first + w[j];
        q.push({-d[v[j]], v[j]});
      }
    }
  }
  return d[t];
}
int main() {
  scanf("%d %d %d %d %d", &n, &m, &L, &s, &t);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %I64d", &u[i], &v[i], &ow[i]);
    v[i + m] = u[i];
    u[i + m] = v[i];
    ow[i + m] = ow[i];
    G[u[i]].push_back(i);
    G[v[i]].push_back(i + m);
  }
  for (int i = 0; i < 2 * m; i++) {
    if (ow[i] == 0)
      w[i] = 1;
    else
      w[i] = ow[i];
  }
  long long lowerbound = dijkstra();
  for (int i = 0; i < 2 * m; i++) {
    if (ow[i] == 0)
      w[i] = 1LL << 50;
    else
      w[i] = ow[i];
  }
  long long upperbound = dijkstra();
  if ((L < lowerbound) || (upperbound < L)) {
    printf("NO\n");
    return 0;
  }
  int Li = 0, Ri = m - 1;
  while (Li <= Ri) {
    int mid = (Li + Ri) / 2;
    for (int i = 0; i < m; i++) {
      if (ow[i] != 0) {
        w[i] = ow[i];
        w[i + m] = ow[i];
        continue;
      }
      if (i >= mid) {
        w[i] = w[i + m] = 1;
      } else {
        w[i] = w[i + m] = 1LL << 50;
      }
    }
    long long L_ = dijkstra();
    if (L_ == L) break;
    if (L_ > L) {
      Ri = mid - 1;
    } else {
      w[mid] = w[mid + m] += L - L_;
      L_ = dijkstra();
      if (L_ == L)
        break;
      else {
        Li = mid + 1;
      }
    }
  }
  printf("YES\n");
  for (int i = 0; i < m; i++) printf("%d %d %I64d\n", u[i], v[i], w[i]);
  return 0;
}
