#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-8;
const int MOD = 1e9 + 7;
const int MAXN = 1e3 + 50;
const int MAXM = 1e4 + 50;
int n, m, L, s, t, cnt, no[MAXM << 1];
struct Edge {
  int u, v, nxt;
  long long w;
} E[MAXM << 1];
int tot, Head[MAXN];
void edge_init() {
  tot = 0;
  memset(Head, -1, sizeof(Head));
}
void edge_add(int u, int v, long long w) {
  E[tot].u = u;
  E[tot].v = v;
  E[tot].w = w;
  E[tot].nxt = Head[u];
  Head[u] = tot++;
  E[tot].u = v;
  E[tot].v = u;
  E[tot].w = w;
  E[tot].nxt = Head[v];
  Head[v] = tot++;
}
struct Node {
  int v;
  long long val;
  Node(int vv, long long vval) {
    v = vv;
    val = vval;
  }
  bool operator<(const Node& node) const { return val > node.val; }
};
long long mincost[MAXN];
bool vis[MAXN];
void dijkstra(int start) {
  memset(mincost, 0x3f, sizeof(mincost));
  memset(vis, false, sizeof(vis));
  priority_queue<Node> q;
  while (!q.empty()) q.pop();
  mincost[start] = 0;
  q.push(Node(start, 0));
  while (!q.empty()) {
    Node cur = q.top();
    q.pop();
    int u = cur.v;
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = Head[u]; ~i; i = E[i].nxt) {
      int v = E[i].v;
      if (!vis[v] && mincost[v] > mincost[u] + E[i].w) {
        mincost[v] = mincost[u] + E[i].w;
        q.push(Node(v, mincost[v]));
      }
    }
  }
}
long long work(long long w) {
  for (int i = 0; i < cnt; i++) E[no[i]].w = w;
  dijkstra(s);
  return mincost[t];
}
int main() {
  while (~scanf("%d%d%d%d%d", &n, &m, &L, &s, &t)) {
    edge_init();
    cnt = 0;
    for (int i = 0; i < m; i++) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      edge_add(u, v, w);
      if (w == 0) {
        no[cnt++] = tot - 2;
        no[cnt++] = tot - 1;
      }
    }
    if (work(1) > L || work(1e18) < L) {
      printf("NO\n");
      continue;
    }
    long long l = 1, h = 1e18;
    while (l <= h) {
      long long mid = (l + h) / 2;
      if (work(mid) >= L)
        h = mid - 1;
      else
        l = mid + 1;
    }
    long long sp = work(l);
    if (sp != L) {
      long long chx = sp - L;
      int i = 0;
      while (true) {
        E[no[i]].w -= min(chx, l - 1);
        E[no[i] + 1].w -= min(chx, l - 1);
        dijkstra(s);
        if (mincost[t] == L) break;
        i = (i + 2) % cnt;
      }
    }
    printf("YES\n");
    for (int i = 0; i < tot; i += 2)
      printf("%d %d %I64d\n", E[i].u, E[i].v, E[i].w);
  }
  return 0;
}
