#include <bits/stdc++.h>
using namespace std;
queue<long long> q;
const long long INF = 1e16;
long long n, m, l, s, t, tot = 0;
bool exist[3000001];
struct data2 {
  long long u, v, w;
} e[3000001];
struct data {
  long long next, num, w;
} edge[3000001];
struct data3 {
  long long dis, num;
  bool operator<(const data3 &p) const { return dis > p.dis; }
};
priority_queue<data3> q2;
long long head[100001];
long long dis[1001][1001], dis2[100001], fa[100001], p[100001], pa[100001],
    h[100001], f[1001][1001];
long long dis3[100001], kg[100001];
void add(long long u, long long v, long long w) {
  edge[++tot].next = head[u];
  edge[tot].num = v;
  edge[tot].w = w;
  head[u] = tot;
}
void dijkstra(long long s) {
  for (long long i = 0; i < n; i++) dis[s][i] = INF;
  memset(exist, 0, sizeof(exist));
  dis[s][s] = 0;
  data3 now;
  now.dis = 0;
  now.num = s;
  q2.push(now);
  for (int i = 2; i <= n; i++) {
    data3 nowx;
    bool judge = 1;
    while (1) {
      if (q2.empty()) {
        judge = 0;
        break;
      }
      nowx = q2.top();
      q2.pop();
      if (exist[nowx.num]) continue;
      break;
    }
    if (!judge) break;
    exist[nowx.num] = 1;
    for (int j = head[nowx.num]; j != -1; j = edge[j].next) {
      int kx = edge[j].num;
      if (dis[s][nowx.num] + edge[j].w < dis[s][kx]) {
        dis[s][kx] = dis[s][nowx.num] + edge[j].w;
        data3 nowx2;
        nowx2.num = kx;
        nowx2.dis = dis[s][kx];
        q2.push(nowx2);
      }
    }
  }
}
void spfa1() {
  memset(exist, 0, sizeof(exist));
  for (long long i = 0; i < n; i++) dis2[i] = INF;
  dis2[s] = 0;
  q.push(s);
  exist[s] = 1;
  while (!q.empty()) {
    long long k = q.front();
    q.pop();
    exist[k] = 0;
    for (long long i = head[k]; i != -1; i = edge[i].next) {
      long long kx = edge[i].num;
      long long noww = edge[i].w;
      if (noww < 0) noww = 1;
      if (dis2[k] + noww < dis2[kx]) {
        dis2[kx] = dis2[k] + noww;
        fa[kx] = k;
        pa[kx] = i;
        if (!exist[kx]) {
          exist[kx] = 1;
          q.push(kx);
        }
      }
    }
  }
}
void spfa2() {
  for (long long i = 0; i < n; i++) dis3[i] = INF;
  memset(exist, 0, sizeof(exist));
  dis3[0] = 0;
  q.push(0);
  exist[0] = 1;
  while (!q.empty()) {
    long long k = q.front();
    q.pop();
    exist[k] = 0;
    for (long long i = head[k]; i != -1; i = edge[i].next) {
      long long kx = edge[i].num;
      if (dis3[k] + edge[i].w < dis3[kx]) {
        dis3[kx] = dis3[k] + edge[i].w;
        if (!exist[kx]) {
          exist[kx] = 1;
          q.push(kx);
        }
      }
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%lld%lld%lld%lld%lld", &n, &m, &l, &s, &t);
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld%lld", &e[i].u, &e[i].v, &e[i].w);
    if (e[i].w) {
      add(e[i].u, e[i].v, e[i].w);
      add(e[i].v, e[i].u, e[i].w);
    }
  }
  for (long long i = 0; i < n; i++) dijkstra(i);
  if (dis[s][t] < l) {
    printf("NO\n");
    return 0;
  }
  for (long long i = 1; i <= m; i++)
    if (e[i].w == 0) {
      add(e[i].u, e[i].v, -i);
      add(e[i].v, e[i].u, -i);
    }
  spfa1();
  if (dis2[t] > l) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  long long nowtot = 0, nowt = t;
  while (nowt != s) {
    h[++nowtot] = pa[nowt];
    p[nowtot] = fa[nowt];
    nowt = fa[nowt];
  }
  long long noww = l - dis2[t];
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) f[i][j] = 1e10;
  p[0] = t;
  long long nowxx = 0;
  for (long long i = nowtot; i >= 1; i--) {
    long long nowsum = 0, nowg = nowxx;
    for (long long j = i; j >= 1; j--) {
      if (edge[h[j]].w >= 0)
        nowsum += edge[h[j]].w;
      else
        nowg++;
      f[nowxx + 1][nowg] =
          min(f[nowxx + 1][nowg], dis[p[i]][edge[h[j]].num] - nowsum);
    }
    if (edge[h[i]].w < 0) {
      nowxx++;
      kg[nowxx] = -edge[h[i]].w;
    }
  }
  memset(head, -1, sizeof(head));
  for (long long i = 1; i <= nowxx; i++) add(i, i - 1, -1);
  for (long long i = 1; i <= nowxx; i++)
    for (long long j = i; j <= nowxx; j++) add(i - 1, j, f[i][j]);
  spfa2();
  for (long long i = 1; i <= nowxx; i++) {
    long long nowans = min(noww, dis3[i] - dis3[i - 1] - 1);
    noww -= nowans;
    e[kg[i]].w = nowans + 1;
  }
  for (long long i = 1; i <= m; i++)
    if (e[i].w <= 0)
      printf("%lld %lld 10000000000000\n", e[i].u, e[i].v);
    else
      printf("%lld %lld %lld\n", e[i].u, e[i].v, e[i].w);
  return 0;
}
