#include <bits/stdc++.h>
const int MAXN = 1010;
int n, m, l, s, t;
long long ans[10010];
bool vis[10010];
struct edge {
  int v, w;
  edge *nxt;
};
struct graph {
  edge *head[MAXN];
  inline void adde(int u, int v, int w) {
    edge *p = new edge;
    p->v = v;
    p->w = w;
    p->nxt = head[u];
    head[u] = p;
  }
  struct node {
    int i;
    long long di;
    node(int i = 0, long long di = 0) : i(i), di(di) {}
    bool operator<(const node &rhs) const { return di > rhs.di; }
  };
  std::priority_queue<node> q;
  long long dis[MAXN];
  inline void spfa(int S, bool firsttime) {
    while (!q.empty()) q.pop();
    if (firsttime) {
      memset(dis, 0x3f, sizeof(dis));
      dis[S] = 0;
      q.push(node(S, 0));
    } else {
      for (int i = 0; i < n; i++) q.push(node(i, dis[i]));
    }
    while (!q.empty()) {
      node u = q.top();
      q.pop();
      if (u.di != dis[u.i]) continue;
      for (edge *i = head[u.i]; i != NULL; i = i->nxt) {
        int v = i->v;
        if (i->w == 0) continue;
        if (dis[v] > dis[u.i] + ans[i->w]) {
          dis[v] = dis[u.i] + ans[i->w];
          q.push(node(v, dis[v]));
        }
      }
    }
  }
} S;
struct data {
  int u, v, id;
  data(int u = 0, int v = 0, int id = 0) : u(u), v(v), id(id) {}
} stk[10010];
int top = 0;
inline void printans(int ptr) {
  puts("YES");
  for (int u = 0; u < n; u++) {
    for (edge *i = S.head[u]; i != NULL; i = i->nxt) {
      int v = i->v;
      if (vis[i->w]) continue;
      printf("%d %d %lld\n", u, v, ans[i->w]);
      vis[i->w] = 1;
    }
  }
  for (int i = ptr; i <= top; i++)
    printf("%d %d %lld\n", stk[i].u, stk[i].v, (long long)1e18);
}
int main() {
  scanf("%d%d%d%d%d", &n, &m, &l, &s, &t);
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    if (w == 0) {
      stk[++top] = data(u, v, i);
      ans[i] = (long long)1e15;
      continue;
    }
    S.adde(u, v, i);
    S.adde(v, u, i);
    ans[i] = w;
  }
  S.spfa(s, 1);
  if (S.dis[t] < l) {
    puts("NO");
    return 0;
  }
  if (S.dis[t] == l) {
    printans(1);
    return 0;
  }
  for (int i = 1; i <= top; i++) {
    ans[stk[i].id] = 1;
    S.adde(stk[i].u, stk[i].v, stk[i].id);
    S.adde(stk[i].v, stk[i].u, stk[i].id);
    if (S.spfa(s, 0), S.dis[t] <= l) {
      ans[stk[i].id] = l - S.dis[t] + 1;
      printans(i + 1);
      return 0;
    }
  }
  puts("NO");
  return 0;
}
