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;
const int maxn = 200100;
int n, m, s, t, cnt = 1;
int to[maxn], head[maxn], Next[maxn], c[maxn], u[maxn], v[maxn], last[maxn],
    path[maxn], ok[maxn];
long long w[maxn], d1[maxn], d2[maxn], l;
bool vis[maxn];
void no_answer() {
  puts("NO");
  exit(0);
}
void ins(int u, int v, int w) {
  to[++cnt] = v;
  Next[cnt] = head[u];
  c[cnt] = w;
  head[u] = cnt;
}
void insert(int u, int v, int w) {
  ins(u, v, w);
  ins(v, u, w);
}
void dijkstra1(int s, int t) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  memset(vis, 0, sizeof(vis));
  memset(d1, 0x3f, sizeof(d1));
  d1[s] = 0;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    pair<int, int> tmp = pq.top();
    pq.pop();
    int u = tmp.second;
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; i; i = Next[i]) {
      int v = to[i];
      long long w = c[i];
      if (d1[v] > d1[u] + w) {
        d1[v] = d1[u] + w;
        pq.push(make_pair(d1[v], v));
      }
    }
  }
}
void dijkstra2(int s, int t) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      pq;
  memset(vis, 0, sizeof(vis));
  memset(d2, 0x3f, sizeof(d2));
  d2[s] = 0;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    pair<int, int> tmp = pq.top();
    pq.pop();
    int u = tmp.second;
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = head[u]; i; i = Next[i]) {
      int v = to[i];
      long long w = c[i];
      if (d2[v] > d2[u] + w) {
        d2[v] = d2[u] + w;
        last[v] = i;
        pq.push(make_pair(d2[v], v));
      }
    }
  }
}
int main() {
  memset(ok, 0, sizeof(ok));
  scanf("%d%d%lld%d%d", &n, &m, &l, &s, &t);
  cnt = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%lld", &u[i], &v[i], &w[i]);
    if (w[i]) insert(u[i], v[i], w[i]);
  }
  dijkstra1(s, t);
  if (d1[t] < l) no_answer();
  memset(head, 0, sizeof(head));
  cnt = 1;
  for (int i = 0; i < m; i++) {
    if (!w[i]) w[i] = 1, ok[i] = 1;
    insert(u[i], v[i], w[i]);
  }
  dijkstra2(s, t);
  if (d2[t] > l) no_answer();
  puts("YES");
  long long tot = l - d2[t];
  for (int i = 0; i < m; i++) {
    if (ok[i]) w[i] = (long long)0x3f3f3f3f * (long long)100;
  }
  for (int i = t; i != s; i = to[last[i] ^ 1]) {
    path[to[last[i] ^ 1]] = last[i];
  }
  for (int i = s; i != t; i = to[path[i]])
    if (ok[(path[i] >> 1) - 1]) w[(path[i] >> 1) - 1] = 1;
  for (int i = s; i != t; i = to[path[i]]) {
    if (ok[(path[i] >> 1) - 1]) {
      w[(path[i] >> 1) - 1] = l - d2[t] + 1;
      dijkstra2(s, t);
      if (d2[t] == l) break;
    }
  }
  for (int i = 0; i < m; i++) printf("%d %d %lld\n", u[i], v[i], w[i]);
  return 0;
}
