#include <bits/stdc++.h>
using namespace std;
int n, m, l, s, t;
vector<int> adj[1123];
int weight[1123][1123];
int dij[1123], dij2[1123];
int fir[11234], sec[11234];
bool vis[1123];
bool desco[1123][1123];
void dijkstra() {
  memset(vis, false, sizeof(vis));
  dij[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pq.push(pair<int, int>(0, s));
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = 0; i < (int)adj[u].size(); i++) {
      int v = adj[u][i];
      int w = weight[u][v];
      if (dij[u] + w < dij[v]) {
        dij[v] = dij[u] + w;
        pq.push(pair<int, int>(dij[v], v));
      }
    }
  }
}
bool dijkstra2(int need) {
  memset(vis, false, sizeof(vis));
  dij2[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pq.push(pair<int, int>(0, s));
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = 0; i < (int)adj[u].size(); i++) {
      int v = adj[u][i];
      int w = weight[u][v];
      if ((dij2[u] + w < dij2[v]) && (desco[u][v]) &&
          (dij2[u] + w < dij[v] + need)) {
        w = weight[u][v] = weight[v][u] = dij[v] + need - dij2[u];
      }
      if (dij2[u] + w < dij2[v]) {
        dij2[v] = dij2[u] + w;
        pq.push(pair<int, int>(dij2[v], v));
      }
    }
  }
  if (dij2[t] != l) return false;
  return true;
}
int main() {
  memset(desco, false, sizeof(desco));
  scanf("%d %d %d %d %d", &n, &m, &l, &s, &t);
  int u, v, w;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &u, &v, &w);
    if (w == 0) {
      weight[u][v] = 1;
      desco[u][v] = true;
      weight[v][u] = 1;
      desco[v][u] = true;
    } else {
      weight[u][v] = w;
      weight[v][u] = w;
    }
    adj[u].push_back(v);
    adj[v].push_back(u);
    fir[i] = u;
    sec[i] = v;
  }
  for (int i = 0; i < n; i++) {
    dij[i] = 1e9 + 5;
    ;
    dij2[i] = 1e9 + 5;
    ;
  }
  dijkstra();
  int need = l - dij[t];
  if (need < 0) {
    printf("NO\n");
    return 0;
  }
  if (dij[t] == l) {
    printf("YES\n");
    for (int i = 0; i < m; i++) {
      u = fir[i];
      v = sec[i];
      printf("%d %d %d\n", u, v, weight[u][v]);
    }
    return 0;
  }
  bool aux = dijkstra2(need);
  if (!aux) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  for (int i = 0; i < m; i++) {
    u = fir[i];
    v = sec[i];
    printf("%d %d %d\n", u, v, weight[u][v]);
  }
  return 0;
}
