#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e3 + 10;
const long long N = 2e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long n, m, l, s, t, dis[maxn], dis2[maxn], wi[maxn][maxn], fedge[N],
    sedge[N], par[maxn];
vector<pair<long long, long long> > adj[maxn];
vector<long long> adj2[maxn];
void dij() {
  fill(dis, dis + n, inf);
  dis[s] = 0;
  queue<long long> q;
  q.push(s);
  while (!q.empty()) {
    long long fr = q.front();
    q.pop();
    for (auto i : adj[fr]) {
      if (dis[i.first] > dis[fr] + i.second) {
        dis[i.first] = dis[fr] + i.second;
        q.push(i.first);
      }
    }
  }
}
bool dij2() {
  fill(dis, dis + n, inf);
  dis[s] = 0;
  par[s] = s;
  queue<long long> q;
  q.push(s);
  while (!q.empty()) {
    long long fr = q.front();
    q.pop();
    for (auto i : adj2[fr]) {
      if (dis[i] > dis[fr] + abs(wi[fr][i])) {
        dis[i] = dis[fr] + abs(wi[fr][i]);
        par[i] = fr;
        q.push(i);
      }
    }
  }
  if (dis[t] > l) return false;
  long long u = t;
  while (u != s) {
    int v = par[u];
    if (wi[v][u] < 0) wi[v][u]--, wi[u][v]--;
    u = v;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (wi[i][j] == -1) wi[i][j] = inf;
  u = t;
  while (u != s) {
    int v = par[u];
    if (wi[u][v] < 0) wi[u][v] = -1, wi[v][u] = -1;
    u = v;
  }
  return true;
}
bool again() {
  fill(dis, dis + n + 1, inf);
  dis[s] = 0;
  queue<long long> q;
  q.push(s);
  while (!q.empty()) {
    long long fr = q.front();
    q.pop();
    for (auto i : adj2[fr]) {
      if (dis[i] > dis[fr] + abs(wi[fr][i])) {
        dis[i] = dis[fr] + abs(wi[fr][i]);
        par[i] = fr;
        q.push(i);
      }
    }
  }
  if (dis[t] == l) return true;
  long long u = t;
  while (u != s) {
    long long v = par[u];
    if (wi[u][v] < 0) {
      long long w = wi[u][v];
      wi[u][v] = abs(w) + (l - dis[t]), wi[v][u] = abs(w) + (l - dis[t]);
      break;
    }
    u = v;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> l >> s >> t;
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    if (w > 0) {
      adj[u].push_back({v, w}), adj[v].push_back({u, w});
      adj2[u].push_back(v), adj2[v].push_back(u);
      wi[u][v] = w, wi[v][u] = w;
    } else {
      adj2[u].push_back(v), adj2[v].push_back(u);
      wi[u][v] = -1, wi[v][u] = -1;
    }
    fedge[i] = u, sedge[i] = v;
  }
  dij();
  if (dis[t] < l)
    return cout << "NO" << endl, 0;
  else if (dis[t] == l) {
    cout << "YES" << endl;
    for (long long i = 0; i < m; i++) {
      long long u = fedge[i], v = sedge[i], w = wi[u][v];
      if (w == -1) w = inf;
      cout << u << " " << v << " " << w << endl;
    }
    return 0;
  }
  if (!dij2()) return cout << "NO" << endl, 0;
  while (!again()) {
    continue;
  }
  cout << "YES" << endl;
  for (long long i = 0; i < m; i++) {
    cout << fedge[i] << " " << sedge[i] << " " << abs(wi[sedge[i]][fedge[i]])
         << endl;
  }
  return 0;
}
