#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
const int maxm = 1e4 + 10;
const long long inf = 1e9 + 10;
int n, m, l, s, t, v1[maxm], v2[maxm], w[maxm], p[maxn], ide[maxn][maxn];
long long d[maxn];
bool marked[maxn];
vector<int> g[maxn];
set<pair<long long, int>> st;
void relax(int v) {
  marked[v] = true;
  for (int id : g[v]) {
    int u = (v1[id] == v ? v2[id] : v1[id]), wi = (w[id] == 0 ? 1 : w[id]);
    if (!marked[u]) {
      if (d[v] + wi < d[u]) {
        st.erase(make_pair(d[u], u));
        d[u] = d[v] + wi;
        st.insert(make_pair(d[u], u));
        p[u] = v;
      }
    }
  }
}
void dijkstra() {
  for (int i = 0; i < n; i++) d[i] = inf, marked[i] = false;
  d[s] = 0;
  st.insert(make_pair(0, s));
  while (!st.empty()) {
    int v = (*st.begin()).second;
    st.erase(st.begin());
    relax(v);
  }
}
int main() {
  cin >> n >> m >> l >> s >> t;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &v1[i], &v2[i], &w[i]);
    if (w[i] > 0) {
      g[v1[i]].push_back(i);
      g[v2[i]].push_back(i);
    }
    ide[v1[i]][v2[i]] = ide[v2[i]][v1[i]] = i;
  }
  dijkstra();
  if (d[t] < l) {
    cout << "NO" << endl;
    return 0;
  } else if (d[t] == l) {
    cout << "YES" << endl;
    for (int i = 0; i < m; i++) {
      cout << v1[i] << ' ' << v2[i] << ' ' << (w[i] == 0 ? inf : w[i]) << endl;
    }
    return 0;
  }
  for (int i = 0; i < m; i++) {
    if (w[i] == 0) {
      g[v1[i]].push_back(i);
      g[v2[i]].push_back(i);
    }
  }
  dijkstra();
  if (d[t] > l) {
    cout << "NO" << endl;
    return 0;
  }
  int v = t;
  while (v != s) {
    if (w[ide[v][p[v]]] == 0) w[ide[v][p[v]]] = -1;
    v = p[v];
  }
  for (int i = 0; i < m; i++) {
    if (w[i] == 0)
      w[i] = inf;
    else if (w[i] == -1)
      w[i] = 0;
  }
  while (d[t] < l) {
    v = t;
    while (v != s) {
      if (w[ide[v][p[v]]] == 0) {
        w[ide[v][p[v]]] = l - d[t] + 1;
        break;
      }
      v = p[v];
    }
    dijkstra();
  }
  cout << "YES" << endl;
  for (int i = 0; i < m; i++) {
    cout << v1[i] << ' ' << v2[i] << ' ' << (w[i] == 0 ? 1 : w[i]) << endl;
  }
  return 0;
}
