#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long, long long>, long long> > vf;
vector<pair<long long, long long> > adj[1008];
vector<int> num[1008];
long long n;
long long m;
long long l;
long long s, t;
long long st[10008], nd[10008], val[10008];
int var[10008] = {0};
long long vis[1008] = {0};
void dfs(long long u) {
  if (vis[u]) return;
  vis[u] = 1;
  long long sz = adj[u].size();
  for (int j = 0; j < sz; j++) {
    pair<long long, long long> v = adj[u][j];
    dfs((long long)v.first);
  }
}
int main() {
  scanf("%lld", &n);
  scanf("%lld", &m);
  scanf("%lld", &l);
  scanf("%lld", &s);
  scanf("%lld", &t);
  for (long long i = 0; i < m; i++) {
    long long u, v;
    long long w;
    scanf("%lld", &u);
    scanf("%lld", &v);
    scanf("%lld", &w);
    st[i] = u;
    nd[i] = v;
    val[i] = w;
    if (!w) var[i] = 1;
    adj[u].push_back(pair<long long, long long>(v, w));
    num[u].push_back(i);
    adj[v].push_back(pair<long long, long long>(u, w));
    num[v].push_back(i);
  }
  dfs(s);
  if (!vis[t]) {
    cout << "NO";
    return 0;
  }
  vector<long long> dist;
  dist.resize(1008, 1000000000000000000ll);
  dist[s] = 0;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push(pair<long long, long long>(0, s));
  while (!pq.empty()) {
    pair<long long, long long> front = pq.top();
    pq.pop();
    long long d = front.first, u = front.second;
    if (d > dist[u]) continue;
    for (long long j = 0; j < (long long)adj[u].size(); j++) {
      pair<long long, long long> v = adj[u][j];
      long long ex = 1000000000000000000ll;
      if (v.second == 0)
        ;
      else
        ex = v.second;
      if (dist[u] + ex < dist[v.first]) {
        dist[v.first] = dist[u] + ex;
        pq.push(pair<long long, long long>(dist[v.first], v.first));
      }
    }
  }
  if (dist[t] < l) {
    cout << "NO";
    return 0;
  } else if (dist[t] == l) {
    printf("YES\n");
    for (long long i = 0; i < m; i++) {
      long long ex = (val[i] ? val[i] : 1000000000000000000ll);
      printf("%llu %llu %llu\n", st[i], nd[i], ex);
    }
    return 0;
  }
  while (!pq.empty()) pq.pop();
  dist.clear();
  dist.resize(1008, 1000000000000000000ll);
  dist[t] = 0;
  pq.push(pair<long long, long long>(0, t));
  while (!pq.empty()) {
    pair<long long, long long> front = pq.top();
    pq.pop();
    long long d = front.first, u = front.second;
    if (d > dist[u]) continue;
    for (long long j = 0; j < (long long)adj[u].size(); j++) {
      pair<long long, long long> v = adj[u][j];
      long long ex = max(v.second, 1ll);
      if (dist[u] + ex < dist[v.first]) {
        dist[v.first] = dist[u] + ex;
        pq.push(pair<long long, long long>(dist[v.first], v.first));
      }
    }
  }
  if (dist[s] > l) {
    cout << "NO";
    return 0;
  }
  while (!pq.empty()) pq.pop();
  vector<int> diss(1008, 1000000007);
  diss[s] = 0;
  pq.push(pair<long long, long long>(0, s));
  while (!pq.empty()) {
    pair<long long, long long> front = pq.top();
    pq.pop();
    long long d = front.first, u = front.second;
    if (d > diss[u]) continue;
    for (long long j = 0; j < (long long)adj[u].size(); j++) {
      pair<long long, long long> v = adj[u][j];
      if (var[num[u][j]]) {
        val[num[u][j]] = v.second =
            max(val[num[u][j]], max(1ll, l - dist[v.first] - diss[u]));
      }
      long long ex = v.second;
      if (diss[u] + ex < diss[v.first]) {
        diss[v.first] = diss[u] + ex;
        pq.push(pair<long long, long long>(diss[v.first], v.first));
      }
    }
  }
  printf("YES");
  printf("\n");
  for (int i = 0; i < m; i++) {
    printf("%llu %llu %llu\n", st[i], nd[i], (val[i] ? val[i] : l));
  }
}
