#include <bits/stdc++.h>
using namespace std;
int N, M, L, S, T, cost[1000 + 3][1000 + 3], prv[1000 + 3];
bool isFixedEdge[1000 + 3][1000 + 3];
pair<int, int> edges[10000 + 3];
vector<int> adj[1000 + 3];
long long int dist[1000 + 3];
long long int Dijkstra(bool onlyUseFixedEdges) {
  for (int i = 0; i < N; i++) {
    dist[i] = 1e15;
    prv[i] = -1;
  }
  dist[S] = 0;
  priority_queue<pair<long long int, int> > pq;
  pq.push({-dist[S], S});
  while (!pq.empty()) {
    auto top = pq.top();
    pq.pop();
    int u = top.second;
    for (auto v : adj[u]) {
      if (onlyUseFixedEdges && !isFixedEdge[u][v]) continue;
      if (dist[v] > dist[u] + cost[u][v]) {
        dist[v] = dist[u] + cost[u][v];
        prv[v] = u;
        pq.push({-dist[v], v});
      }
    }
  }
  return dist[T];
}
int main() {
  scanf("%d%d%d%d%d", &N, &M, &L, &S, &T);
  memset(cost, -1, sizeof(cost));
  memset(isFixedEdge, true, sizeof(isFixedEdge));
  for (int i = 0; i < M; i++) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    if (c == 0) {
      isFixedEdge[u][v] = isFixedEdge[v][u] = false;
      c = 1;
    }
    edges[i] = {u, v};
    cost[u][v] = cost[v][u] = c;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  long long int sp;
  sp = Dijkstra(true);
  if (sp < L) {
    printf("NO\n");
    return 0;
  }
  sp = Dijkstra(false);
  if (sp > L) {
    printf("NO\n");
    return 0;
  }
  while (true) {
    sp = Dijkstra(false);
    if (sp == L) break;
    int current = T;
    while (prv[current] != -1) {
      if (!isFixedEdge[prv[current]][current]) {
        cost[prv[current]][current] += (L - sp);
        cost[current][prv[current]] += (L - sp);
        break;
      }
      current = prv[current];
    }
  }
  printf("YES\n");
  for (int i = 0; i < M; i++) {
    printf("%d %d %d\n", edges[i].first, edges[i].second,
           cost[edges[i].first][edges[i].second]);
  }
}
