#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e3 + 20, maxm = 1e4 + 20, inf = 1e17;
bool mark[maxn], vis[maxm];
vector<pair<int, int>> graph[maxn];
long long dis[maxn], w[maxm], n, m, l, s, e, from[maxm], to[maxm];
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    q;
void dij() {
  fill(dis, dis + maxn, inf);
  memset(mark, 0, sizeof mark);
  q.push({dis[s] = 0, s});
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    if (mark[x]) continue;
    mark[x] = 1;
    for (auto u : graph[x])
      if (dis[x] + w[u.second] < dis[u.first])
        q.push({dis[u.first] = dis[x] + w[u.second], u.first});
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> l >> s >> e;
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v >> w[i];
    from[i] = u, to[i] = v;
    graph[u].push_back({v, i});
    graph[v].push_back({u, i});
    if (!w[i]) vis[i] = 1, w[i] = 1;
  }
  dij();
  if (dis[e] > l) return cout << "NO" << endl, 0;
  for (int i = 0; i < m; i++)
    if (vis[i]) {
      dij();
      w[i] += max(0ll, l - dis[e]);
    }
  dij();
  if (dis[e] == l) {
    cout << "YES" << endl;
    for (int i = 0; i < m; i++)
      cout << from[i] << " " << to[i] << " " << w[i] << endl;
  } else
    cout << "NO" << endl;
}
