#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
const int N = 1e3 + 9, M = 1e4 + 9;
int n, m, L, s, t;
pair<pair<int, int>, long long> edge[M];
bool marked[M];
pair<long long, int> dist[N];
vector<pair<int, int>> g[N];
long long dijk() {
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      pq;
  for (int i = 0; i < n; i++) dist[i] = {INF, i};
  dist[s] = {0, 0};
  for (pq.push({0, s}); !pq.empty();) {
    long long cst = pq.top().first;
    int u = pq.top().second;
    pq.pop();
    if (cst != dist[u].first) continue;
    for (auto it : g[u]) {
      if (cst + edge[it.second].second < dist[it.first].first) {
        dist[it.first] = {cst + edge[it.second].second, it.second};
        pq.push({dist[it.first].first, it.first});
      }
    }
  }
  return dist[t].first;
}
void trace_back(int u) {
  int num_edge = dist[u].second;
  if (marked[num_edge]) {
    edge[num_edge].second = L - dist[t].first + 1;
    return;
  }
  int v = edge[num_edge].first.first;
  if (v == u) v = edge[num_edge].first.second;
  trace_back(v);
}
void pr() {
  cout << "YES" << '\n';
  for (int i = 1; i <= m; i++) {
    cout << edge[i].first.first << " " << edge[i].first.second << " "
         << edge[i].second << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m >> L >> s >> t;
  for (int i = 1; i <= m; i++) {
    cin >> edge[i].first.first >> edge[i].first.second >> edge[i].second;
    if (edge[i].second == 0) {
      marked[i] = 1;
    } else {
      g[edge[i].first.first].emplace_back(edge[i].first.second, i);
      g[edge[i].first.second].emplace_back(edge[i].first.first, i);
    }
  }
  if (dijk() < L) {
    cout << "NO" << '\n';
    return 0;
  }
  if (dijk() == L) {
    for (int i = 1; i <= m; i++)
      if (marked[i]) edge[i].second = INF;
    pr();
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    if (marked[i]) {
      edge[i].second = 1;
      g[edge[i].first.first].emplace_back(edge[i].first.second, i);
      g[edge[i].first.second].emplace_back(edge[i].first.first, i);
      ;
    }
  }
  if (dijk() > L) {
    cout << "NO" << '\n';
    return 0;
  }
  while (dijk() < L) {
    trace_back(t);
  }
  pr();
  return 0;
}
