#include <bits/stdc++.h>
using namespace std;
long long int n, m, weight, src, des;
vector<vector<pair<long long int, long long int>>> adj;
map<pair<long long int, long long int>, long long int> Zedges;
vector<vector<long long int>> matrix;
vector<long long int> dis, parent;
long long int dij() {
  dis.clear();
  parent.clear();
  dis.assign(n, 1e17);
  parent.assign(n, -1);
  set<vector<long long int>> s;
  s.insert({0, src});
  dis[src] = 0;
  while (!s.empty()) {
    auto it = s.begin();
    long long int u = (*it)[1];
    s.erase(it);
    for (auto &p : adj[u]) {
      long long int v = p.first, w = p.second;
      if (dis[v] > dis[u] + w) {
        s.erase({dis[v], v});
        dis[v] = dis[u] + w;
        parent[v] = u;
        s.insert({dis[v], v});
      }
    }
  }
  return dis[des];
}
void getpath(long long int p, vector<long long int> &ans) {
  if (dis[p] == 1e17) return;
  if (parent[p] == -1) {
    ans.push_back(p);
    return;
  }
  getpath(parent[p], ans);
  ans.push_back(p);
}
void Print() {
  cout << "YES" << endl;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i + 1; j < n; j++) {
      if (matrix[i][j] != 1e17)
        cout << i << " " << j << " " << matrix[i][j] << endl;
    }
  }
  for (auto &p : Zedges) {
    if (p.second == 0) p.second = 1e17;
    cout << p.first.first << " " << p.first.second << " " << p.second << endl;
  }
  return;
}
void solve(long long int T) {
  cin >> n >> m >> weight >> src >> des;
  adj.resize(n);
  matrix.resize(n, vector<long long int>(n, 1e17));
  for (long long int i = 0; i < m; i++) {
    long long int u, v, w;
    cin >> u >> v >> w;
    if (w == 0) {
      Zedges[{u, v}] = 0;
      continue;
    }
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
    matrix[u][v] = w;
    matrix[v][u] = w;
  }
  long long int D = dij();
  if (D < weight) {
    cout << "NO" << endl;
    return;
  }
  if (D == weight) {
    Print();
    return;
  }
  for (auto &e : Zedges) {
    long long int u = e.first.first, v = e.first.second;
    adj[u].push_back({v, 1});
    adj[v].push_back({u, 1});
    long long int newD = dij();
    if (newD <= weight) {
      long long int rem = weight - newD;
      e.second = 1 + rem;
      Print();
      return;
    }
    e.second = 1;
  }
  cout << "NO" << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T = 1;
  for (long long int t = 1; t <= T; t++) {
    solve(t);
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
