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 long long max1 = 11;
const long long max2 = 102;
const long long max3 = 1003;
const long long max4 = 10004;
const long long maxx = 2005;
const long long max6 = 1000006;
const long long max7 = 10000007;
const long long lg2 = 7;
const long long lg3 = 10;
const long long lg4 = 13;
const long long lg5 = 17;
const long long lg6 = 20;
const long long lg7 = 24;
const long long lg8 = 27;
const long long lg9 = 30;
const long long lg18 = 60;
const long long INF = 2000000000005;
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) {
  while (b) b ^= a ^= b ^= a %= b;
  return a;
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long is_prime(long long n) {
  if (n == 1) return 0;
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  for (long long i = 3; i <= sqrt(n); i += 2)
    if (n % i == 0) return 0;
  return 1;
}
long long is_integer(double n) {
  if (floor(n) == ceil(n)) return 1;
  return 0;
}
long long sto_int(string s) {
  stringstream ss(s);
  long long n;
  ss >> n;
  return n;
}
string to_string(long long n) {
  stringstream ss;
  ss << n;
  string s = ss.str();
  return s;
}
struct edge {
  long long u, v, w;
  edge(){};
  edge(long long a, long long b, long long c) { u = a, v = b, w = c; }
  long long other(long long a) {
    if (a == u)
      return v;
    else
      return u;
  }
};
long long n, m, L, s, t;
edge E[maxx];
vector<long long> g[maxx];
long long a, b, c;
vector<long long> idx;
long long dis[maxx];
void Dijkstra(long long s, long long t) {
  for (long long i = 1; i <= n; i++) dis[i] = INF;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      Q;
  Q.push({0, s});
  dis[s] = 0;
  while (!Q.empty()) {
    long long cur = Q.top().second;
    Q.pop();
    for (long long i = 0; i < g[cur].size(); i++) {
      long long to = E[g[cur][i]].other(cur);
      if (dis[to] > dis[cur] + E[g[cur][i]].w)
        dis[to] = dis[cur] + E[g[cur][i]].w, Q.push({dis[to], to});
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  ;
  cin >> n >> m >> L >> s >> t;
  s++, t++;
  for (long long i = 1; i <= m; i++) {
    cin >> a >> b >> c;
    E[i] = edge(a + 1, b + 1, c);
    if (c > 0)
      g[a + 1].push_back(i), g[b + 1].push_back(i);
    else
      idx.push_back(i);
  }
  Dijkstra(s, t);
  long long d = dis[t];
  if (d < L) {
    cout << "NO" << endl;
    return 0;
  }
  if (d == L) {
    cout << "YES" << endl;
    for (long long i = 1; i <= m; i++)
      cout << E[i].u - 1 << " " << E[i].v - 1 << " "
           << (E[i].w == 0 ? INF : E[i].w) << endl;
    return 0;
  }
  for (long long tt = 0; tt < idx.size(); tt++) {
    long long in = idx[tt];
    E[in].w = 1;
    g[E[in].u].push_back(in);
    g[E[in].v].push_back(in);
    Dijkstra(s, t);
    d = dis[t];
    if (d <= L) {
      E[in].w += L - d;
      d = L;
      break;
    } else {
    }
  }
  if (d != L) {
    cout << "NO" << endl;
    return 0;
  } else {
    cout << "YES" << endl;
    for (long long i = 1; i <= m; i++)
      cout << E[i].u - 1 << " " << E[i].v - 1 << " "
           << (E[i].w == 0 ? INF : E[i].w) << endl;
  }
  return 0;
}
