#include <bits/stdc++.h>
using namespace std;
vector<long long> dijkstra(vector<vector<pair<int, int>>> g, int s) {
  vector<long long> dist(g.size(), (long long)1e18);
  dist[s] = 0;
  priority_queue<pair<long long, int>> pq;
  pq.push(make_pair(-dist[s], s));
  while (!pq.empty()) {
    auto cur = pq.top();
    pq.pop();
    if (dist[cur.second] != -cur.first) continue;
    int v = cur.second;
    for (auto e : g[v]) {
      if (dist[e.first] > dist[v] + e.second) {
        dist[e.first] = dist[v] + e.second;
        pq.push(make_pair(-dist[e.first], e.first));
      }
    }
  }
  return dist;
}
int get(vector<int> &p, int s) {
  if (p[s] == s) return s;
  return p[s] = get(p, p[s]);
}
void join(vector<int> &p, int a, int b) {
  a = get(p, a);
  b = get(p, b);
  p[a] = b;
}
int main() {
  int n, m, L, s, t;
  cin >> n >> m >> L >> s >> t;
  vector<pair<pair<int, int>, int>> edges(m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &edges[i].first.first, &edges[i].first.second,
          &edges[i].second);
  }
  vector<vector<pair<int, int>>> g(n);
  for (auto e : edges) {
    if (e.second == 0) {
      g[e.first.first].push_back(make_pair(e.first.second, 1));
      g[e.first.second].push_back(make_pair(e.first.first, 1));
    } else {
      g[e.first.first].push_back(make_pair(e.first.second, e.second));
      g[e.first.second].push_back(make_pair(e.first.first, e.second));
    }
  }
  if (dijkstra(g, s)[t] > L) {
    printf("NO\n");
    return 0;
  }
  g = vector<vector<pair<int, int>>>(n);
  for (auto e : edges) {
    if (e.second != 0) {
      g[e.first.first].push_back(make_pair(e.first.second, e.second));
      g[e.first.second].push_back(make_pair(e.first.first, e.second));
    }
  }
  if (dijkstra(g, s)[t] < L) {
    printf("NO\n");
    return 0;
  }
  long long left = 1;
  long long right = (int)1e9 + 1;
  while (left + 1 < right) {
    int ave = (left + right) / 2;
    g = vector<vector<pair<int, int>>>(n);
    for (auto e : edges) {
      if (e.second == 0) {
        g[e.first.first].push_back(make_pair(e.first.second, ave));
        g[e.first.second].push_back(make_pair(e.first.first, ave));
      } else {
        g[e.first.first].push_back(make_pair(e.first.second, e.second));
        g[e.first.second].push_back(make_pair(e.first.first, e.second));
      }
    }
    if (dijkstra(g, s)[t] <= L) {
      left = ave;
    } else {
      right = ave;
    }
  }
  int W = left;
  left = 0;
  right = m;
  while (left + 1 < right) {
    int ave = (left + right) / 2;
    g = vector<vector<pair<int, int>>>(n);
    for (int i = 0; i < m; i++) {
      auto e = edges[i];
      if (e.second == 0) {
        g[e.first.first].push_back(
            make_pair(e.first.second, W + 1 - (i >= ave)));
        g[e.first.second].push_back(
            make_pair(e.first.first, W + 1 - (i >= ave)));
      } else {
        g[e.first.first].push_back(make_pair(e.first.second, e.second));
        g[e.first.second].push_back(make_pair(e.first.first, e.second));
      }
    }
    if (dijkstra(g, s)[t] <= L) {
      left = ave;
    } else {
      right = ave;
    }
  }
  printf("YES\n");
  for (int i = 0; i < m; i++) {
    auto e = edges[i];
    if (e.second == 0) {
      e.second = W + 1 - (i >= left);
    }
    printf("%d %d %d\n", e.first.first, e.first.second, e.second);
  }
}
