#include <bits/stdc++.h>
using namespace std;
const int N = 1010, inf = 1e9 + 1;
int n, m, s, t, u, v, w, L;
struct edge {
  int u, v, w;
  bool erased;
  edge(int u = 0, int v = 0, int w = 0, bool erased = false)
      : u(u), v(v), w(w), erased(erased){};
} edges[10010];
int dists[N], par[N];
vector<int> adj[N];
int get(int i, int u) { return edges[i].u + edges[i].v - u; }
int dijkstra() {
  for (int i = 0; i < n; i++) dists[i] = inf;
  dists[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  pq.push({0, s});
  while (!pq.empty()) {
    int u = pq.top().second, d = pq.top().first;
    pq.pop();
    if (u == t) break;
    if (dists[u] < d) continue;
    for (int id : adj[u]) {
      int v = get(id, u), w = edges[id].w;
      if (d + w < dists[v]) {
        dists[v] = d + w;
        par[v] = id;
        pq.push({dists[v], v});
      }
    }
  }
  return dists[t];
}
void no() {
  printf("NO");
  exit(0);
}
void print() {
  printf("YES\n");
  for (int i = 0; i < m; ++i) {
    printf("%d %d %d\n", edges[i].u, edges[i].v, edges[i].w);
  }
  exit(0);
}
int main() {
  scanf("%d %d %d %d %d", &n, &m, &L, &s, &t);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", &u, &v, &w);
    edges[i] = (w == 0 ? edge(u, v, inf, true) : edge(u, v, w, false));
    adj[u].push_back(i);
    adj[v].push_back(i);
  }
  if (dijkstra() >= L) {
    for (int i = 0; i < m; ++i)
      if (edges[i].erased) edges[i].w = 1;
    if (dijkstra() <= L) {
      int tt = t;
      while (tt != s) {
        int id = par[tt];
        if (edges[id].erased) edges[id].w = 0;
        tt = get(id, tt);
      }
      for (int i = 0; i < m; ++i)
        if (edges[i].erased) edges[i].w = (edges[i].w == 0 ? 1 : inf);
      while (dists[t] < L) {
        int tt = t;
        while (tt != s) {
          int id = par[tt];
          if (edges[id].erased) {
            edges[id].w = L - dists[t] + edges[id].w;
            break;
          }
          tt = get(id, tt);
        }
        dijkstra();
      }
      printf("YES\n");
      for (int i = 0; i < m; ++i) {
        printf("%d %d %d\n", edges[i].u, edges[i].v, edges[i].w);
      }
      return 0;
    }
  }
  printf("NO");
  return 0;
}
