#include <bits/stdc++.h>
using namespace std;
const double eps = (double)1e-10;
const int INF = (int)0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e4 + 10;
const int MAXM = (int)1e4 + 10;
int n, m, s, t;
long long L;
long long dist[MAXN];
bool vis[MAXN];
int mark[MAXN];
struct Edge {
  int u, v;
  long long w;
  int next;
} edge[MAXM << 1];
int head[MAXN];
int edgenum;
void Add_Edge(int u, int v, long long w) {
  edge[edgenum].u = u;
  edge[edgenum].v = v;
  edge[edgenum].w = w;
  edge[edgenum].next = head[u];
  head[u] = edgenum++;
}
void SPFA_BFS(int s) {
  queue<int> q;
  for (int i = 0; i < MAXN; i++) dist[i] = INF;
  dist[s] = 0;
  memset(vis, 0, sizeof(vis));
  q.push(s);
  vis[s] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = head[u]; i != -1; i = edge[i].next) {
      int v = edge[i].v;
      long long w = edge[i].w;
      if (dist[u] + w < dist[v]) {
        dist[v] = dist[u] + w;
        if (!vis[v]) {
          vis[v] = 1;
          q.push(v);
        }
      }
    }
  }
}
void work() {
  scanf("%d%d%I64d%d%d", &n, &m, &L, &s, &t);
  memset(head, -1, sizeof(head));
  edgenum = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%I64d", &u, &v, &w);
    if (w == 0) {
      w = 1;
      mark[i] = 1;
    }
    Add_Edge(u, v, w);
    Add_Edge(v, u, w);
  }
  SPFA_BFS(s);
  if (dist[t] == INF || dist[t] > L) {
    printf("NO\n");
    return;
  }
  long long delta = L - dist[t];
  int ok = 0;
  if (dist[t] == L) ok = 1;
  if (!ok) {
    for (int i = 0; i < m; i++) {
      if (mark[i]) {
        edge[i * 2].w += delta;
        edge[i * 2 + 1].w += delta;
        SPFA_BFS(s);
        if (dist[t] == L) {
          ok = 1;
          break;
        } else
          delta = L - dist[t];
      }
    }
  }
  if (!ok)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 0; i < m; i++) {
      printf("%d %d %I64d\n", edge[i * 2].u, edge[i * 2].v, edge[i * 2].w);
    }
  }
}
int main() {
  work();
  return 0;
}
