#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
int n, m, L, s, t, visited[N], dist[N], pop[N];
map<pair<int, int>, int> mp;
priority_queue<pair<int, int> > Q;
vector<pair<int, int> > G[N];
void dijkstra() {
  fill(dist, dist + n, 1e9 + 7);
  dist[s] = 0;
  pop[s] = -1;
  fill(visited, visited + n, 0);
  Q.push({0, s});
  while (!Q.empty()) {
    int u = Q.top().second;
    Q.pop();
    if (visited[u]) continue;
    visited[u] = true;
    for (int i = 0; i < (int)G[u].size(); i++) {
      int v = G[u][i].first;
      int c = G[u][i].second;
      if (dist[u] + c < dist[v]) {
        dist[v] = dist[u] + c;
        pop[v] = u;
        Q.push({-dist[v], v});
      }
    }
  }
}
int main() {
  scanf("%d%d%d%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);
    if (c == 0) {
      mp[{a, b}] = G[a].size();
      mp[{b, a}] = G[b].size();
      c = 1;
    }
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }
  bool check = true;
  while (check) {
    dijkstra();
    if (dist[t] > L) {
      check = false;
      break;
    }
    if (dist[t] == L) break;
    check = false;
    int k = t;
    while (pop[k] != -1) {
      if (mp.count({k, pop[k]})) {
        auto &a1 = G[k][mp[{k, pop[k]}]].second;
        auto &a2 = G[pop[k]][mp[{pop[k], k}]].second;
        a1 += L - dist[t];
        a2 += L - dist[t];
        check = true;
        break;
      }
      k = pop[k];
    }
  }
  if (!check)
    puts("NO");
  else {
    puts("YES");
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < (int)G[i].size(); j++)
        if (G[i][j].first > i)
          printf("%d %d %d\n", i, G[i][j].first, G[i][j].second);
    }
  }
  return 0;
}
