#include <bits/stdc++.h>
using namespace std;
const int N = 1005, M = 10005;
const long long INF = 1e9 + 5;
struct sl {
  int x, y, f, last;
  long long v;
} line[2 * M];
int S, T, n, m, z, x, y, num, que[1000005], ans, mid, last[N], to[M], tn;
long long L, dis[N];
bool c[N];
void add(int x, int y, long long v) {
  line[++num].x = x;
  line[num].y = y;
  if (v == 0)
    line[num].v = 1, line[num].f = 0;
  else
    line[num].v = v, line[num].f = 1;
  line[num].last = last[x];
  last[x] = num;
}
void spfa() {
  int now, h, t;
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= n; ++i) dis[i] = INF;
  dis[S] = 0;
  h = 0;
  c[S] = true;
  que[t = 1] = S;
  while (h <= t) {
    now = que[++h];
    for (int j = last[now]; j; j = line[j].last)
      if (dis[line[j].y] > dis[now] + line[j].v) {
        dis[line[j].y] = dis[now] + line[j].v;
        if (c[line[j].y] == false) {
          c[line[j].y] = true;
          que[++t] = line[j].y;
        }
      }
    c[now] = false;
  }
}
long long check(int l) {
  for (int i = 1; i <= l; ++i) {
    line[2 * to[i]].v = line[2 * to[i] + 1].v = 1;
  }
  for (int i = l + 1; i <= tn; ++i) {
    if (line[2 * to[i]].f) continue;
    line[2 * to[i]].v = line[2 * to[i] + 1].v = INF;
  }
  spfa();
  return dis[T];
}
void output() {
  printf("YES\n");
  for (int i = 1; i <= m; ++i)
    printf("%d %d %I64d\n", line[2 * i].x - 1, line[2 * i].y - 1,
           line[2 * i].v);
  exit(0);
}
int main() {
  scanf("%d%d%I64d%d%d", &n, &m, &L, &S, &T);
  ++S;
  ++T;
  num = 1;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    ++x;
    ++y;
    add(x, y, z);
    add(y, x, z);
    if (z == 0) to[++tn] = i;
  }
  spfa();
  if (dis[T] > L) {
    printf("NO\n");
    return 0;
  }
  if (dis[T] == L) output();
  for (int i = 1; i <= tn; ++i) {
    line[to[i] * 2].v = line[to[i] * 2 + 1].v = INF;
  }
  spfa();
  if (dis[T] == L) output();
  if (dis[T] < L) {
    printf("NO\n");
    return 0;
  }
  int l = 1, r = tn, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(mid) > L)
      l = mid + 1;
    else if (check(mid) == L)
      output();
    else {
      ans = mid;
      r = mid - 1;
    }
  }
  line[to[ans] * 2].v = line[to[ans] * 2 + 1].v = 1;
  spfa();
  line[to[ans] * 2].v += L - dis[T];
  output();
}
