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 mod = 1000000007;
const int N = 10010;
int n, m, l, s, t, p[N];
long long a, b, w, cost[N];
bool vis[N];
vector<pair<int, long long> > g[N];
vector<pair<pair<int, int>, long long> > edges;
map<pair<int, int>, long long> newDistance;
map<pair<int, int>, int> block;
struct state {
  int lastIdx;
  int src;
  int parent;
  long long cost;
  state(int _src, int _parent, long long _cost) {
    src = _src;
    cost = _cost;
    parent = _parent;
  }
  state(int _src, long long _cost) {
    src = _src;
    cost = _cost;
  }
  bool operator<(const state &rhs) const { return cost > rhs.cost; }
};
void dijsktra(int u) {
  priority_queue<state> q;
  for (int i = 0; i <= n; i++) cost[i] = 1e18;
  q.push(state(u, 0));
  cost[u] = 0;
  while (!q.empty()) {
    state u = q.top();
    q.pop();
    if (vis[u.src]) continue;
    vis[u.src] = 1;
    for (int i = 0; i < g[u.src].size(); ++i) {
      pair<int, long long> v = g[u.src][i];
      if (v.second + u.cost < cost[v.first] && v.second) {
        cost[v.first] = v.second + u.cost;
        q.push(state(v.first, cost[v.first]));
      }
    }
  }
}
void di2(int u) {
  priority_queue<state> q;
  for (int i = 0; i <= n; i++) cost[i] = 1e18;
  memset(vis, 0, sizeof vis);
  q.push(state(u, 0));
  cost[u] = 0;
  while (!q.empty()) {
    state u = q.top();
    q.pop();
    if (vis[u.src]) continue;
    vis[u.src] = 1;
    p[u.src] = u.parent;
    for (int i = 0; i < g[u.src].size(); ++i) {
      pair<int, long long> v = g[u.src][i];
      int second = v.second;
      if (second == 0) second++;
      if (second + u.cost < cost[v.first]) {
        cost[v.first] = second + u.cost;
        q.push(state(v.first, u.src, cost[v.first]));
      }
    }
  }
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &l, &s, &t);
  for (int i = 0; i < m; ++i) {
    scanf("%lld%lld%lld", &a, &b, &w);
    edges.push_back(make_pair(make_pair(a, b), w));
    g[a].push_back(make_pair(b, w));
    g[b].push_back(make_pair(a, w));
    newDistance[make_pair(a, b)] = newDistance[make_pair(b, a)] = w;
  }
  dijsktra(s);
  if (cost[t] < (long long)l) {
    puts("NO");
  } else {
    di2(s);
    if (cost[t] > l) {
      puts("NO");
    } else if (cost[t] <= l) {
      long long rem = l;
      int cur = t;
      int AnsA = -1, AnsB = -1;
      while (cur != s) {
        int prev = p[cur];
        block[make_pair(cur, prev)] = block[make_pair(prev, cur)] = 1;
        if (newDistance[make_pair(cur, prev)] != 0) {
          rem -= newDistance[make_pair(cur, prev)];
        } else {
          newDistance[make_pair(cur, prev)] =
              newDistance[make_pair(prev, cur)] = 1;
          AnsA = cur;
          AnsB = prev;
          rem--;
        }
        cur = prev;
      }
      newDistance[make_pair(AnsB, AnsA)] += rem;
      newDistance[make_pair(AnsA, AnsB)] += rem;
      for (int i = 0; i < edges.size(); i++) {
        a = edges[i].first.first;
        b = edges[i].first.second;
        if (!block[make_pair(a, b)] && edges[i].second == 0) {
          edges[i].second = 1e18;
        }
        if (block[make_pair(a, b)]) {
          edges[i].second = newDistance[make_pair(a, b)];
        }
      }
      puts("YES");
      for (int i = 0; i < m; ++i) {
        printf("%d %d %lld\n", edges[i].first.first, edges[i].first.second,
               edges[i].second);
      }
    }
  }
  return 0;
}
