#include <bits/stdc++.h>
using namespace std;
class edge {
 public:
  int u, v;
  long long w;
  edge() {}
  edge(int nu, int nv, long long nw) { u = nu, v = nv, w = nw; }
};
const int maxn = 1e3;
const long long inf = 1e18;
vector<pair<int, int>> adj[maxn];
int n, m, L;
vector<edge> e;
vector<bool> edit;
vector<long long> d;
vector<int> pred;
vector<int> path;
long long dijkstra(int s, int t, long long val) {
  d.assign(n, inf);
  pred.assign(n, -1);
  path.clear();
  d[s] = 0;
  using pr = pair<long long, int>;
  priority_queue<pr, vector<pr>, greater<pr>> Q;
  Q.push({0, s});
  while (!Q.empty()) {
    int now = Q.top().second;
    long long d_now = Q.top().first;
    Q.pop();
    if (d_now != d[now]) continue;
    for (auto x : adj[now]) {
      int to = x.first, i = x.second;
      long long len;
      if (edit[i])
        len = val;
      else
        len = e[i].w;
      if (d[to] > d[now] + len) {
        d[to] = d[now] + len;
        pred[to] = i;
        Q.push({d[to], to});
      }
    }
  }
  int u = t, v, ei = pred[t];
  while (ei != -1) {
    path.push_back(ei);
    if (u == e[ei].u)
      v = e[ei].v;
    else
      v = e[ei].u;
    u = v;
    ei = pred[u];
  }
  return d[t];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s, t;
  cin >> n >> m >> L >> s >> t;
  e.resize(m);
  edit.resize(m, false);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
    e[i] = edge(u, v, w);
    if (w == 0) {
      edit[i] = true;
    }
  }
  long long mind = dijkstra(s, t, 1), maxd = dijkstra(s, t, inf);
  if (L < mind || maxd < L) {
    cout << "NO\n";
    return 0;
  } else if (L < maxd) {
    long long dist = dijkstra(s, t, 1);
    while (dist != L) {
      long long need = L - dist;
      for (auto i : path) {
        if (edit[i]) {
          e[i].w = 1 + need;
          edit[i] = false;
          break;
        }
      }
      dist = dijkstra(s, t, 1);
    }
    for (int i = 0; i < m; i++)
      if (edit[i]) {
        e[i].w = 1;
        edit[i] = false;
      }
  }
  cout << "YES\n";
  for (int i = 0; i < m; i++) {
    cout << e[i].u << " " << e[i].v << " " << (edit[i] ? inf : e[i].w) << "\n";
  }
  return 0;
}
