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;
template <class T, class U>
void maximize(T &x, U y) {
  if (x < y) x = y;
}
template <class T, class U>
void minimize(T &x, U y) {
  if (x > y) x = y;
}
template <class T>
T Abs(T x) {
  return (x < 0 ? -x : x);
}
template <class T>
T safe_sqrt(T x) {
  return sqrt(max(x, (T)0));
}
template <class T, class U, class V>
T addmod(T x, U k, V MOD) {
  return ((x + k) % MOD + MOD) % MOD;
}
template <class T, class U, class V>
T submod(T x, U k, V MOD) {
  return ((x - k) % MOD + MOD) % MOD;
}
template <class T, class U, class V>
T mul(T x, U y, V MOD) {
  return (long long)x * y % MOD;
}
namespace task {
const long long inf = 1e18;
const int N = 1e3 + 3;
vector<pair<int, int> > adj[N];
struct E {
  int u, v, w;
  E() {}
  E(int _u, int _v, int _w) : u(_u), v(_v), w(_w) {}
} edge[10 * N];
int n, m, L, s, t;
long long dist[2][N];
bool mark[N];
void print() {
  puts("YES");
  for (int i = 1; i <= m; ++i)
    printf("%d %d %d\n", edge[i].u - 1, edge[i].v - 1, edge[i].w);
}
void dijkstra1() {
  priority_queue<pair<long long, int> > heap;
  fill(dist[0] + 1, dist[0] + 1 + n, inf);
  dist[0][t] = 0;
  heap.push(make_pair(dist[0][t], t));
  while (!heap.empty()) {
    pair<long long, int> top = heap.top();
    heap.pop();
    int u = top.second;
    if (dist[0][u] != -top.first) continue;
    for (auto e : adj[u])
      if (dist[0][u] + edge[e.second].w < dist[0][e.first])
        dist[0][e.first] = dist[0][u] + edge[e.second].w,
        heap.push(make_pair(-dist[0][e.first], e.first));
  }
}
void dijkstra2() {
  priority_queue<pair<long long, int> > heap;
  fill(dist[1] + 1, dist[1] + 1 + n, inf);
  dist[1][s] = 0;
  heap.push(make_pair(dist[1][s], s));
  while (!heap.empty()) {
    pair<long long, int> top = heap.top();
    heap.pop();
    int u = top.second;
    if (dist[1][u] != -top.first) continue;
    for (auto e : adj[u])
      if (dist[1][u] + edge[e.second].w < dist[1][e.first] and
          dist[1][u] + edge[e.second].w + dist[0][e.first] < L) {
        if (mark[e.second])
          edge[e.second].w +=
              L - (dist[1][u] + edge[e.second].w + dist[0][e.first]);
        else {
          dist[1][e.first] = dist[1][u] + edge[e.second].w;
          heap.push(make_pair(-dist[1][e.first], e.first));
        }
      }
  }
}
void solve() {
  scanf("%d%d%d%d%d", &n, &m, &L, &s, &t);
  ++s, ++t;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &edge[i].u, &edge[i].v, &edge[i].w);
    ++edge[i].u, ++edge[i].v;
    if (!edge[i].w) edge[i].w = 1, mark[i] = true;
    adj[edge[i].u].push_back(make_pair(edge[i].v, i));
    adj[edge[i].v].push_back(make_pair(edge[i].u, i));
  }
  dijkstra1();
  if (dist[0][s] > L) puts("NO"), exit(0);
  if (dist[0][s] == L) print(), exit(0);
  dijkstra2();
  if (dist[1][t] == inf)
    print();
  else
    puts("NO");
}
}  // namespace task
int main(void) { task::solve(); }
