7 9 999999999 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 7 9 320 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 4 5 7 0 3
0 1 0
1 2 3
2 3 0
0 2 5
1 3 5
 8 9 10 1 0
1 2 1
2 4 1
1 3 0
3 4 0
4 5 0
5 6 1
6 0 1
5 7 0
7 0 0
 4 4 14 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 5 6 1000000000 0 4
0 1 1
2 0 2
3 0 3
4 1 0
4 2 0
3 4 0
 4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
 4 4 2 1 3
1 3 13
2 3 0
2 0 0
1 0 0
 5 5 2 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 5 5 3 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 4 4 8 1 3
1 3 13
2 3 0
2 0 0
1 0 6
 1000 1 1000000000 998 0
0 999 0
 5 5 1 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 100 1 123456 99 0
0 99 123456
 4 4 13 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 7 9 319 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 1000 1 5 999 0
0 999 0

YES
0 1 1
1 2 999999996
2 3 999999997
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 YES
0 1 1
1 2 199
2 3 318
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 1 3
1 2 3
2 3 2
0 2 5
1 3 5
 YES
1 2 1
2 4 1
1 3 1
3 4 1
4 5 6
5 6 1
6 0 1
5 7 1
7 0 1
 NO YES
0 1 1
2 0 2
3 0 3
4 1 999999999
4 2 999999998
3 4 999999997
 NO NO YES
0 1 1
1 2 1
0 4 1
4 3 1
3 2 1
 NO YES
1 3 13
2 3 1
2 0 1
1 0 6
 NO NO YES
0 99 123456
 YES
1 3 13
2 3 1
2 0 1
1 0 12
 YES
0 1 1
1 2 198
2 3 317
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 999 5

#include <bits/stdc++.h>
using namespace std;
struct Node {
  int uu, vv;
  long long dis;
} v[20005], temp;
int flag[10005], fm = 0, n, m, root[1005], fa[200005], s, t;
long long ans[1005];
bool life[1005];
queue<int> q;
void go() {
  int now, t;
  memset(ans, 0, sizeof(ans));
  ans[s] = 1;
  q.push(s);
  life[s] = 1;
  while (!q.empty()) {
    now = q.front();
    q.pop();
    t = root[now];
    life[now] = 0;
    while (t) {
      if (ans[now] + v[t].dis < ans[v[t].vv] || !ans[v[t].vv]) {
        ans[v[t].vv] = ans[now] + v[t].dis;
        if (!life[v[t].vv]) {
          life[v[t].vv] = 1;
          q.push(v[t].vv);
        }
      }
      t = fa[t];
    }
  }
  return;
}
void ok() {
  printf("YES\n");
  for (int i = 1; i <= m; i++) {
    printf("%d %d %I64d\n", v[i].uu, v[i].vv, v[i].dis);
  }
}
int main() {
  long long L, dis;
  int uu, vv;
  int nl = 1, nr = L, mid;
  cin >> n >> m >> L >> s >> t;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%I64d", &uu, &vv, &dis);
    temp.uu = uu;
    temp.vv = vv;
    temp.dis = dis;
    v[i] = temp;
    if (dis == 0) flag[fm++] = i;
    fa[i] = root[uu];
    root[uu] = i;
    temp.uu = vv;
    temp.vv = uu;
    v[i + n] = temp;
    fa[i + n] = root[vv];
    root[vv] = i + n;
  }
  L++;
  for (int i = 0; i < fm; i++) v[flag[i]].dis = v[flag[i] + n].dis = 1;
  go();
  if (ans[t] == L)
    ok();
  else {
    if (ans[t] > L)
      printf("NO\n");
    else {
      for (int i = 0; i < fm; i++) v[flag[i]].dis = v[flag[i] + n].dis = L;
      go();
      if (ans[t] == L)
        ok();
      else {
        if (ans[t] < L)
          printf("NO\n", ans[t]);
        else {
          for (int i = 0; i < fm; i++) {
            v[flag[i]].dis = v[flag[i] + n].dis = 1;
            go();
            if (ans[t] <= L) {
              if (ans[t] == L)
                ok();
              else {
                nl = 1;
                nr = L;
                while (1) {
                  mid = (nl + nr) / 2;
                  v[flag[i]].dis = v[flag[i] + n].dis = mid;
                  go();
                  if (ans[t] == L) {
                    ok();
                    break;
                  } else {
                    if (ans[t] < L)
                      nl = mid;
                    else
                      nr = mid;
                  }
                }
              }
              break;
            }
          }
        }
      }
    }
  }
  return 0;
}
