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;
int mult(int x, int y) {
  long long int ans, x1 = (long long int)x, y1 = (long long int)y;
  ans = (x1 * y1) % 1000000007;
  return (int)ans;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
long long int pow1(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int mina(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] < x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
int maxa(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] > x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
vector<vector<pair<long long int, long long int> > > v;
vector<long long int> dist;
multiset<pair<long long int, long long int> > pq;
vector<long long int> prev1;
vector<pair<long long int, long long int> > e;
long long int w[100005];
int f[100005];
long long int dijkstra(long long int n, long long int src, long long int des) {
  pq.clear();
  int i;
  for (i = 0; i < n + 2; i++) dist[i] = 1000000000000000000;
  pq.insert(make_pair(src, 0));
  dist[src] = 0;
  pair<long long int, long long int> front;
  long long int d, ver;
  while (pq.size()) {
    front = *pq.begin();
    pq.erase(front);
    d = -front.second;
    ver = front.first;
    if (d > dist[ver]) continue;
    for (vector<pair<long long int, long long int> >::iterator itr =
             v[ver].begin();
         itr != v[ver].end(); itr++) {
      int ind = (*itr).first, v1 = (*itr).second;
      if (dist[ver] + w[ind] < dist[v1]) {
        prev1[v1] = ind;
        dist[v1] = dist[ver] + w[ind];
        pq.insert(make_pair(v1, -dist[v1]));
      }
    }
  }
  if (ver == des) return dist[des];
}
bool fun(long long int st, long long int dest, long long int add) {
  long long int curr = dest;
  while (curr != st) {
    int ind = prev1[curr];
    if (f[ind] == 1) {
      w[ind] += add;
      return true;
    }
    if (curr == e[ind].second)
      curr = e[ind].first;
    else
      curr = e[ind].second;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  long long int x, y, w1, n, i, m, l, s, t;
  cin >> n >> m >> l >> s >> t;
  v.resize(n + 4);
  dist.resize(n + 4);
  for (i = 0; i < n + 4; i++) dist[i] = 1000000000000000000;
  prev1.resize(n + 2);
  for (i = 0; i < m; i++) {
    cin >> x >> y >> w1;
    v[x].push_back(make_pair(i, y));
    v[y].push_back(make_pair(i, x));
    e.push_back(make_pair(x, y));
    w[i] = w1;
    if (!w[i]) w[i]++, f[i] = 1;
  }
  while (true) {
    long long int d = dijkstra(n, s, t);
    if (d > l) {
      cout << "NO" << endl;
      return 0;
    }
    if (d == l) break;
    if (fun(s, t, l - d) == false) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (i = 0; i < m; i++)
    cout << e[i].first << " " << e[i].second << " " << w[i] << endl;
  return 0;
}
