#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int N = 10100;
struct HeapNode {
  long long d;
  int u;
  bool operator<(const HeapNode &u) const { return d > u.d; }
};
struct Edge {
  int u, v, claim;
  long long cost;
};
int n, m, L, s, t;
int done[N];
long long dis[N];
vector<int> g[N];
vector<Edge> edges;
long long dijkstra(int s, int t) {
  memset(done, 0, sizeof done);
  for (int i = 0; i < n; ++i) dis[i] = INF;
  dis[s] = 0;
  priority_queue<HeapNode> q;
  q.push((HeapNode){0, s});
  while (!q.empty()) {
    HeapNode x = q.top();
    q.pop();
    int u = x.u;
    if (done[u]) continue;
    done[u] = 1;
    for (int i = 0; i < (int)g[u].size(); ++i) {
      Edge &e = edges[g[u][i]];
      int to = u ^ e.u ^ e.v;
      if (!done[to] && dis[to] > dis[u] + e.cost) {
        dis[to] = dis[u] + e.cost;
        q.push((HeapNode){dis[to], to});
      }
    }
  }
  return dis[t];
}
int main() {
  cin >> n >> m >> L >> s >> t;
  edges.resize(m);
  for (int i = 0; i < m; ++i) {
    Edge &e = edges[i];
    cin >> e.u >> e.v >> e.claim;
    if (e.claim != 0) e.cost = e.claim;
    g[e.u].push_back(i);
    g[e.v].push_back(i);
  }
  try {
    for (int i = 0; i < m; ++i)
      if (edges[i].claim == 0) edges[i].cost = INF;
    if (dijkstra(s, t) < L) throw 1;
    for (int i = 0; i < m; ++i)
      if (edges[i].claim == 0) edges[i].cost = 1;
    if (dijkstra(s, t) > L) throw 2;
    long long now = dijkstra(s, t);
    for (int i = 0; i < m; ++i)
      if (edges[i].claim == 0) {
        edges[i].cost += L - now;
        now = dijkstra(s, t);
        if (now == L) break;
      }
    assert(now == L);
    puts("YES");
    for (int i = 0; i < m; ++i)
      cout << edges[i].u << " " << edges[i].v << " " << edges[i].cost << endl;
  } catch (int e) {
    puts("NO");
  }
}
