#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 7;
const long long INF = 1000000000000000ll;
vector<pair<int, long long> > g[MAXN];
long long d[MAXN];
long long d_mx[MAXN];
map<pair<int, int>, long long> edges;
set<pair<int, int> > v;
int n, m, s, t;
long long L;
long long upd(int a, int b, long long c) {
  if (edges.count(make_pair(a, b)))
    edges[make_pair(a, b)] = c;
  else
    edges[make_pair(b, a)] = c;
  return c;
}
long long get_c(int a, int b) {
  return edges.count(make_pair(a, b)) ? edges[make_pair(a, b)]
                                      : edges[make_pair(b, a)];
}
bool is_v(int a, int b) {
  return v.count(make_pair(a, b)) + v.count(make_pair(b, a));
}
long long dijkstra(long long need = -1) {
  for (int i = 0; i < MAXN; i++) d[i] = INF;
  set<pair<long long, int> > q;
  d[s] = 0;
  q.insert(make_pair(0, s));
  while (!q.empty()) {
    pair<long long, int> x = *q.begin();
    q.erase(q.begin());
    int u = x.second;
    if (x.first < 0) throw -1;
    for (int i = 0; i < g[u].size(); i++) {
      int to = g[u][i].first;
      long long c = get_c(to, u);
      if (need != -1 && is_v(u, to) && d[to] > d[u] + c &&
          d[u] + c < d_mx[to] + need) {
        c = upd(u, to, d_mx[to] + need - d[u]);
      }
      if (d[to] > d[u] + c) {
        d[to] = d[u] + c;
        q.insert(make_pair(d[to], to));
      }
    }
  }
  return d[t];
}
int main() {
  cin >> n >> m >> L >> s >> t;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
    if (c == 0) {
      v.insert(make_pair(a, b));
      c = 1;
    }
    edges[make_pair(a, b)] = c;
  }
  long long mn = dijkstra();
  for (int i = 0; i < MAXN; i++) d_mx[i] = d[i];
  if (L >= mn) {
    int v = t;
    long long need = L - mn;
    long long sol = dijkstra(need);
    if (sol != L) {
      cout << "NO\n";
      return 0;
    }
    cout << "YES\n";
    for (auto const& x : edges) {
      printf("%d %d %lld \n", x.first.first, x.first.second,
             (x.second == 0 ? INF : x.second));
    }
  } else {
    cout << "NO\n";
  }
  return 0;
}
