#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
int s, t, n, m, L;
;
vector<int> id;
vector<pair<int, int> > e[maxn];
long long dis[maxn];
int u[maxn], v[maxn], d[maxn];
set<pair<long long, int> > hp;
int vis[maxn];
void dij() {
  hp.clear();
  memset(dis, 0x3f, sizeof(dis));
  memset(vis, 0, sizeof(vis));
  dis[s] = 0;
  for (int i = 0; i < n; i++) hp.insert({dis[i], i});
  for (int i = 0; i < n; i++) {
    int u = hp.begin()->second;
    hp.erase(hp.begin());
    vis[u] = 1;
    for (int j = 0; j < e[u].size(); j++) {
      int v = e[u][j].first;
      if (dis[v] > dis[u] + e[u][j].second) {
        hp.erase({dis[v], v});
        dis[v] = dis[u] + e[u][j].second;
        hp.insert({dis[v], v});
      }
    }
  }
}
long long check(long long tmp) {
  for (int i = 0; i < id.size(); i++) {
    d[id[i]] = 1 + min(tmp, 1000000000ll);
    tmp -= d[id[i]] - 1;
  }
  for (int i = 0; i < n; i++) {
    e[i].clear();
  }
  for (int i = 0; i < m; i++) {
    e[u[i]].emplace_back(v[i], d[i]);
    e[v[i]].emplace_back(u[i], d[i]);
  }
  dij();
  return dis[t];
}
int main() {
  scanf("%d %d %d %d %d", &n, &m, &L, &s, &t);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &u[i], &v[i], &d[i]);
    if (d[i] == 0) {
      id.emplace_back(i);
    }
  }
  long long l = 0, r = 1000000000ll * id.size();
  if (check(l) > L || check(r) < L) {
    puts("NO");
    return 0;
  }
  puts("YES");
  long long mid;
  while (l < r) {
    mid = (l + r) >> 1;
    if (check(mid) > L)
      r = mid;
    else if (check(mid) < L)
      l = mid + 1;
    else
      break;
  }
  check(mid);
  for (int i = 0; i < m; i++) {
    printf("%d %d %d\n", u[i], v[i], d[i]);
  }
}
