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 int N = 300010;
const long long mod = 1000000007;
int n, m, p[N], s, t, back[N];
long long L;
long long cost[N];
long long weight[N];
bool vis[N];
struct edge {
  int v, idx;
  long long cost;
  int parent;
  edge(int _v, int _parent, int _idx, long long _cost) {
    v = _v;
    idx = _idx;
    cost = _cost;
    parent = _parent;
  }
  edge(int _v, int _idx) {
    v = _v;
    idx = _idx;
  }
  bool operator<(const edge &rhs) const { return cost > rhs.cost; }
};
struct state {
  int u, v;
  long long cost;
  state() {}
  state(int _u, int _v, long long _cost) {
    u = _u;
    v = _v;
    cost = _cost;
  }
};
vector<edge> g[N];
state e[N];
bool empty[N];
vector<int> used;
bool have[N];
void reset() {
  for (int i = 0; i <= n; i++) {
    cost[i] = 1e18;
    vis[i] = 0;
    p[i] = -1;
    back[i] = -1;
  }
}
void dijsktra(int u) {
  reset();
  priority_queue<edge> q;
  cost[u] = 0;
  q.push(edge(u, -1, -1, 0));
  while (!q.empty()) {
    edge cur = q.top();
    q.pop();
    if (vis[cur.v]) continue;
    vis[cur.v] = 1;
    p[cur.v] = cur.parent;
    back[cur.v] = cur.idx;
    for (int i = 0; i < g[cur.v].size(); i++) {
      edge nxt = g[cur.v][i];
      if (cost[nxt.v] > cost[cur.v] + weight[nxt.idx] && weight[nxt.idx]) {
        cost[nxt.v] = cost[cur.v] + weight[nxt.idx];
        q.push(edge(nxt.v, cur.v, nxt.idx, cost[nxt.v]));
      }
    }
  }
}
int main() {
  scanf("%d%d%lld%d%d", &n, &m, &L, &s, &t);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%lld", &e[i].u, &e[i].v, &weight[i]);
    if (!weight[i]) empty[i] = true;
    g[e[i].u].push_back(edge(e[i].v, i));
    g[e[i].v].push_back(edge(e[i].u, i));
  }
  dijsktra(s);
  if (cost[t] < L) {
    puts("NO");
  } else {
    for (int i = 0; i < m; i++) {
      if (empty[i]) weight[i] = 1;
    }
    dijsktra(s);
    if (cost[t] > L) {
      puts("NO");
    } else {
      puts("YES");
      while (1) {
        dijsktra(s);
        if (cost[t] == L) {
          break;
        } else {
          int curS = t;
          int chng;
          while (curS != s) {
            used.push_back(back[curS]);
            have[used.back()] = true;
            if (empty[used.back()]) {
              chng = used.back();
            }
            curS = p[curS];
          }
          weight[chng] += L - cost[t];
          for (int i = 0; i < m; i++) {
            if (!have[i] && empty[i]) {
              weight[i] = 2e9;
            }
          }
          while (!used.empty() && used.back()) {
            have[used.back()] = 0;
            used.pop_back();
          }
        }
      }
      for (int i = 0; i < m; ++i) {
        printf("%d %d %lld\n", e[i].u, e[i].v, weight[i]);
      }
    }
  }
  return 0;
}
