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 <typename T>
void cmax(T& a, T b) {
  a = max(a, b);
}
template <typename T>
void cmin(T& a, T b) {
  a = min(a, b);
}
void _BG(const char* s) {}
template <typename T, typename... TT>
void _BG(const char* s, T a, TT... b) {
  for (int c = 0; *s && (c || *s != ','); ++s) {
    cerr << *s;
    switch (*s) {
      case '(':
      case '[':
      case '{':
        ++c;
        break;
      case ')':
      case ']':
      case '}':
        --c;
        break;
    }
  }
  cerr << " = " << a;
  if (*s) {
    cerr << ", ";
    _BG(++s, b...);
  } else
    cerr << endl;
}
bool RD(void) { return true; }
bool RD(char& a) { return scanf(" %c", &a) == 1; }
bool RD(char* a) { return scanf("%s", a) == 1; }
bool RD(double& a) { return scanf("%lf", &a) == 1; }
bool RD(int& a) { return scanf("%d", &a) == 1; }
bool RD(long long& a) { return scanf("%lld", &a) == 1; }
template <typename T, typename... TT>
bool RD(T& a, TT&... b) {
  return RD(a) && RD(b...);
}
void PT(const char a) { putchar(a); }
void PT(const char* a) { fputs(a, stdout); }
void PT(char* a) { fputs(a, stdout); }
void PT(const double a) { printf("%.16f", a); }
void PT(const int a) { printf("%d", a); }
void PT(const long long a) { printf("%lld", a); }
template <char sep = ' ', char end = '\n'>
void PL(void) {
  if (end) PT(end);
}
template <char sep = ' ', char end = '\n', typename T, typename... TT>
void PL(const T a, const TT... b) {
  PT(a);
  if (sizeof...(b) && sep) PT(sep);
  PL<sep, end>(b...);
}
const int N = 1234, M = 12345;
const long long inf = 1e18;
struct edge {
  int u, v;
  long long w;
  bool f;
  int go(int x) { return u ^ v ^ x; }
} e[M];
vector<int> g[N];
int n, m, s, t;
long long L, d[N];
int pr[N];
long long sp() {
  fill_n(d, n, inf);
  fill_n(pr, n, -1);
  d[s] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      pq;
  pq.push({0, s});
  while (((int)pq.size())) {
    int u;
    long long w;
    tie(w, u) = pq.top();
    pq.pop();
    if (w > d[u]) continue;
    if (u == t) break;
    for (int i : g[u]) {
      int v = e[i].go(u);
      w = d[u] + e[i].w;
      if (w < d[v]) {
        d[v] = w;
        pr[v] = i;
        pq.push({w, v});
      }
    }
  }
  return d[t];
}
int main() {
  RD(n, m, L, s, t);
  for (int i(0), _B(m); i < _B; ++i) {
    RD(e[i].u, e[i].v, e[i].w);
    if (!e[i].w) {
      e[i].w = 1;
      e[i].f = 1;
    } else {
      g[e[i].u].push_back(i);
      g[e[i].v].push_back(i);
    }
  }
  if (sp() < L) {
    PL("NO");
    return 0;
  }
  for (int i(0), _B(m); i < _B; ++i)
    if (e[i].f) {
      g[e[i].u].push_back(i);
      g[e[i].v].push_back(i);
    }
  long long w = sp();
  if (w > L) {
    PL("NO");
    return 0;
  }
  for (; w < L; w = sp()) {
    for (int k = t; k != s; k = e[pr[k]].go(k)) {
      int i = pr[k];
      if (e[i].f) {
        e[i].w += L - w;
        break;
      }
    }
  }
  PL("YES");
  for (int i(0), _B(m); i < _B; ++i) PL(e[i].u, e[i].v, e[i].w);
}
