#include <bits/stdc++.h>
using namespace std;
struct edg {
  int v, u;
  long long w;
  bool ch = 0, P = 0;
};
const int MAXN = 1e3 + 10, MAXM = 1e4 + 10;
set<pair<long long, pair<int, int> > > S;
int n, m, L, s, t, par[MAXN], ans;
vector<int> Mat[MAXN];
long long dis[MAXN];
bool se[MAXN];
edg e[MAXM];
int gett(int v, int ind) {
  if (e[ind].v == v) return e[ind].u;
  return e[ind].v;
}
void addv(int v) {
  for (int i = 0; i < Mat[v].size(); i++) {
    int t = gett(v, Mat[v][i]);
    if (!se[t]) S.insert({dis[v] + e[Mat[v][i]].w, {t, Mat[v][i]}});
  }
}
void dij() {
  ans = 1;
  for (int i = 1; i <= n; i++) se[i] = 0, dis[i] = 1e18;
  S.insert({0, {s, -1}});
  dis[s] = 0;
  while (!S.empty()) {
    pair<long long, pair<int, int> > T = *S.begin();
    S.erase(S.begin());
    int v = T.second.first, ei = T.second.second;
    long long d = T.first;
    if (se[v]) continue;
    dis[v] = d;
    par[v] = ei;
    se[v] = 1;
    addv(v);
  }
  if (dis[t] == L) {
    ans = 2;
    return;
  }
  if (dis[t] > L) {
    ans = 0;
    return;
  }
  int cur = t;
  bool con = 0;
  while (par[cur] != -1) {
    if (e[par[cur]].ch) {
      if (con == 0) e[par[cur]].w += L - dis[t], con = 1;
      e[par[cur]].P = 1;
    }
    cur = gett(cur, par[cur]);
  }
  for (int i = 0; i < m; i++)
    if (e[i].ch && !e[i].P) e[i].w = 1e16;
  if (!con && dis[t] != L) {
    ans = 0;
    return;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> L >> s >> t;
  s++, t++;
  for (int i = 0; i < m; i++) {
    cin >> e[i].v >> e[i].u >> e[i].w;
    if (e[i].w == 0) e[i].ch = 1, e[i].w = 1;
    e[i].v++, e[i].u++;
    Mat[e[i].v].push_back(i);
    Mat[e[i].u].push_back(i);
  }
  while (1) {
    dij();
    if (ans == 2)
      break;
    else if (ans == 0)
      return cout << "NO", 0;
  }
  cout << "YES" << '\n';
  for (int i = 0; i < m; i++) {
    if (e[i].w == 0) e[i].w = 1;
    cout << e[i].v - 1 << ' ' << e[i].u - 1 << ' ' << e[i].w << '\n';
  }
}
