#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;
const int inf = 0x3f3f3f3f;
const int maxn = 1e3 + 100;
const int maxm = 2e4 + 100;
struct Edge {
  int v, to, id;
  long long w;
} E[maxm];
int head[maxn], cnt;
void addedge(int v, int u, long long w, int id) {
  E[cnt].v = u, E[cnt].w = w, E[cnt].id = id, E[cnt].to = head[v];
  head[v] = cnt++;
}
void init() {
  ;
  memset(head, -1, sizeof(head));
  ;
  cnt = 0;
}
queue<int> Q;
long long dist[maxn];
int vis[maxn];
pair<int, int> pre[maxn];
struct node {
  int v, u;
  long long w;
} P[maxm];
int flag[maxm];
void SPFA(int st, int ed, int n) {
  while (!Q.empty()) Q.pop();
  Q.push(st);
  ;
  memset(vis, 0, sizeof(vis));
  ;
  for (int i = 0; i < n; i++) dist[i] = INF, pre[i].first = pre[i].second = -1;
  dist[st] = 0;
  vis[st] = 1;
  while (!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    vis[cur] = 0;
    for (int i = head[cur]; ~i; i = E[i].to) {
      int v = E[i].v;
      if (dist[v] > dist[cur] + E[i].w) {
        dist[v] = dist[cur] + E[i].w;
        pre[v].first = cur;
        pre[v].second = E[i].id;
        if (!vis[v]) {
          vis[v] = 1;
          Q.push(v);
        }
      } else if (dist[v] == dist[cur] + E[i].w &&
                 (pre[v].second != -1 && flag[pre[v].second])) {
        dist[v] = dist[cur] + E[i].w;
        pre[v].first = cur;
        pre[v].second = E[i].id;
        if (!vis[v]) {
          vis[v] = 1;
          Q.push(v);
        }
      }
    }
  }
}
int main() {
  int n, m, L, s, t;
  scanf("%d%d%d%d%d", &n, &m, &L, &s, &t);
  init();
  for (int i = 0; i < m; i++) {
    scanf("%d%d%lld", &P[i].v, &P[i].u, &P[i].w);
    if (P[i].w == 0) {
      P[i].w = inf;
      flag[i] = 1;
    }
    addedge(P[i].v, P[i].u, P[i].w, i);
    addedge(P[i].u, P[i].v, P[i].w, i);
  }
  SPFA(s, t, n);
  if (dist[t] < L) {
    puts("NO");
    return 0;
  } else if (dist[t] == L) {
    puts("YES");
    for (int i = 0; i < m; i++) printf("%d %d %lld\n", P[i].v, P[i].u, P[i].w);
    return 0;
  }
  for (int i = 0; i < m; i++)
    if (flag[i]) P[i].w = 1;
  init();
  for (int i = 0; i < m; i++) {
    addedge(P[i].v, P[i].u, P[i].w, i);
    addedge(P[i].u, P[i].v, P[i].w, i);
  }
  SPFA(s, t, n);
  if (dist[t] > L) {
    puts("NO");
  } else {
    puts("YES");
    long long cha = L - dist[t];
    int pos;
    while (cha) {
      pos = t;
      while (pre[pos].first != -1) {
        if (flag[pre[pos].second]) {
          P[pre[pos].second].w += cha;
          flag[pre[pos].second] = 0;
          break;
        }
        pos = pre[pos].first;
      }
      init();
      for (int i = 0; i < m; i++) {
        addedge(P[i].v, P[i].u, P[i].w, i);
        addedge(P[i].u, P[i].v, P[i].w, i);
      }
      SPFA(s, t, n);
      cha = L - dist[t];
    }
    pos = t;
    while (pre[pos].first != -1) {
      if (flag[pre[pos].second]) {
        flag[pre[pos].second] = 0;
      }
      pos = pre[pos].first;
    }
    for (int i = 0; i < m; i++)
      if (flag[i]) P[i].w = inf;
    for (int i = 0; i < m; i++) printf("%d %d %lld\n", P[i].v, P[i].u, P[i].w);
  }
  return 0;
}
