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 = 1100, inf = 1e9 + 1;
int e, head[N], done[N], dist[N];
int n, m, L, s, t;
struct Edge {
  int v, w, nx;
} edges[N * N];
void init() {
  e = 0;
  memset(head, -1, sizeof head);
}
void add_edge(int u, int v, int w) {
  edges[e] = (Edge){v, w, head[u]};
  head[u] = e++;
}
struct Node {
  int u, d;
  bool operator<(const Node& o) const { return d > o.d; }
};
void dijkstra() {
  for (int i = 0; i < n; i++) dist[i] = inf, done[i] = 0;
  priority_queue<Node> pq;
  pq.push((Node){s, 0});
  dist[s] = 0;
  while (!pq.empty()) {
    Node x = pq.top();
    pq.pop();
    int u = x.u;
    if (done[u]) continue;
    done[u] = 1;
    for (int i = head[u]; ~i; i = edges[i].nx) {
      int v = edges[i].v;
      int w = edges[i].w;
      if (dist[v] > dist[u] + w) {
        dist[v] = dist[u] + w;
        pq.push((Node){v, dist[v]});
      }
    }
  }
}
vector<Edge> v1, v2;
int check(int x) {
  init();
  for (int i = 0; i < (int)v1.size(); i++) {
    add_edge(v1[i].v, v1[i].w, v1[i].nx);
    add_edge(v1[i].w, v1[i].v, v1[i].nx);
  }
  for (int i = 0; i < x; i++) {
    add_edge(v2[i].v, v2[i].w, 1);
    add_edge(v2[i].w, v2[i].v, 1);
  }
  dijkstra();
  return dist[t];
}
int main() {
  freopen("case.in", "r", stdin);
  scanf("%d%d%d%d%d", &n, &m, &L, &s, &t);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    if (w)
      v1.push_back((Edge){u, v, w});
    else
      v2.push_back((Edge){u, v, w});
  }
  int L1 = check(0), L2 = check(v2.size());
  if (L1 < L || L2 > L) {
    puts("NO");
    return 0;
  }
  if (L1 == L) {
    puts("YES");
    for (int i = 0; i < (int)v1.size(); i++)
      printf("%d %d %d\n", v1[i].v, v1[i].w, v1[i].nx);
    for (int i = 0; i < (int)v2.size(); i++)
      printf("%d %d %d\n", v2[i].v, v2[i].w, inf);
    return 0;
  }
  int low = 0, high = v2.size();
  while (high - low > 1) {
    int M = (low + high) / 2;
    if (check(M) <= L)
      high = M;
    else
      low = M;
  }
  int nowL = check(high);
  puts("YES");
  for (int i = 0; i < (int)v1.size(); i++)
    printf("%d %d %d\n", v1[i].v, v1[i].w, v1[i].nx);
  for (int i = 0; i < high - 1; i++) printf("%d %d %d\n", v2[i].v, v2[i].w, 1);
  printf("%d %d %d\n", v2[high - 1].v, v2[high - 1].w, L - nowL + 1);
  for (int i = high; i < (int)v2.size(); i++)
    printf("%d %d %d\n", v2[i].v, v2[i].w, inf);
  return 0;
}
