#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1010;
const int maxm = 10010;
int n, m, L;
struct qnode {
  int v, c;
  qnode() {}
  qnode(int _v, int _c) : v(_v), c(_c) {}
  bool operator<(const qnode& r) const { return c > r.c; }
};
struct Edge {
  int to, cost;
  Edge(int _to, int _cost) : to(_to), cost(_cost) {}
};
vector<Edge> E[maxn << 2];
bool vis[maxn];
int dist[maxn];
void addedge(int u, int v, int w) { E[u].push_back(Edge(v, w)); }
int dijkstra(int s, int t) {
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i <= n; ++i) dist[i] = inf;
  priority_queue<qnode> que;
  dist[s] = 0;
  que.push(qnode(s, 0));
  qnode tmp;
  while (!que.empty()) {
    tmp = que.top();
    que.pop();
    int u = tmp.v;
    if (u == t) return tmp.c;
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = 0; i < E[u].size(); ++i) {
      int v = E[u][i].to, cost = E[u][i].cost;
      if (!vis[v] && dist[v] > dist[u] + cost) {
        dist[v] = dist[u] + cost;
        que.push(qnode(v, dist[v]));
      }
    }
  }
  return inf;
}
struct edge {
  int u, v, w;
} e[maxm << 1], e0[maxm << 1];
int main() {
  int u, v, w, s, t;
  scanf("%d%d%d%d%d", &n, &m, &L, &s, &t);
  int tot1 = 0, tot2 = 0;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &u, &v, &w);
    if (w != 0) {
      addedge(u, v, w);
      addedge(v, u, w);
      e[tot1].u = u, e[tot1].v = v, e[tot1++].w = w;
    } else
      e0[tot2].u = u, e0[tot2].v = v, e0[tot2++].w = w;
  }
  int ans = dijkstra(s, t);
  if (ans < L)
    printf("NO\n");
  else if (ans == L) {
    printf("YES\n");
    for (int i = 0; i < tot1; ++i) printf("%d %d %d\n", e[i].u, e[i].v, e[i].w);
    for (int i = 0; i < tot2; ++i) printf("%d %d %d\n", e0[i].u, e0[i].v, inf);
  } else {
    int flag = -1;
    for (int i = 0; i < tot2; ++i) {
      addedge(e0[i].u, e0[i].v, 1);
      addedge(e0[i].v, e0[i].u, 1);
      ans = dijkstra(s, t);
      if (ans > L) continue;
      flag = i;
      break;
    }
    if (flag == -1)
      printf("NO\n");
    else {
      printf("YES\n");
      for (int i = 0; i < tot1; ++i)
        printf("%d %d %d\n", e[i].u, e[i].v, e[i].w);
      for (int i = 0; i < flag; ++i) printf("%d %d %d\n", e0[i].u, e0[i].v, 1);
      printf("%d %d %d\n", e0[flag].u, e0[flag].v, L - ans + 1);
      for (int i = flag + 1; i < tot2; ++i)
        printf("%d %d %d\n", e0[i].u, e0[i].v, inf);
    }
  }
  return 0;
}
