#include <bits/stdc++.h>
using namespace std;
int mult(int x, int y) {
  long long int ans, x1 = (long long int)x, y1 = (long long int)y;
  ans = (x1 * y1) % 1000000007;
  return (int)ans;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
long long int pow1(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int mina(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] < x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
int maxa(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] > x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
vector<vector<pair<long long int, long long int> > > v;
vector<long long int> dist;
multiset<pair<long long int, long long int> > pq;
vector<long long int> prev1;
vector<pair<long long int, long long int> > e;
long long int w[10005];
int f[10005];
bool vis[10005];
long long int dijkstra(long long int n, long long int src, long long int des) {
  pq.clear();
  int i;
  for (i = 0; i < n + 2; i++) dist[i] = LLONG_MAX, vis[i] = false;
  ;
  pq.insert(make_pair(0, src));
  dist[src] = 0;
  prev1[src] = -1;
  pair<long long int, long long int> front;
  long long int d, ver;
  while (pq.size()) {
    front = *pq.begin();
    pq.erase(pq.begin());
    d = front.first;
    ver = front.second;
    if (vis[ver]) continue;
    vis[ver] = true;
    if (ver == des) break;
    for (vector<pair<long long int, long long int> >::iterator itr =
             v[ver].begin();
         itr != v[ver].end(); itr++) {
      long long int ind = (*itr).first, v1 = (*itr).second;
      if (vis[v1]) continue;
      if (dist[ver] + w[ind] < dist[v1]) {
        prev1[v1] = ind;
        dist[v1] = dist[ver] + w[ind];
        pq.insert(make_pair(dist[v1], v1));
      }
    }
  }
  return dist[des];
}
bool fun(long long int st, long long int dest, long long int add) {
  long long int curr = dest;
  while (curr != st) {
    long long int ind = prev1[curr];
    if (f[ind] == 1) {
      w[ind] += add;
      return true;
    }
    if (curr == e[ind].second)
      curr = e[ind].first;
    else
      curr = e[ind].second;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  long long int x, y, w1, n, i, m, l, s, t;
  cin >> n >> m >> l >> s >> t;
  v.resize(n + 4);
  dist.resize(n + 4);
  prev1.resize(n + 4);
  for (i = 0; i < m; i++) {
    cin >> x >> y >> w1;
    v[x].push_back(make_pair(i, y));
    v[y].push_back(make_pair(i, x));
    e.push_back(make_pair(x, y));
    w[i] = w1;
    if (!w[i]) w[i]++, f[i] = 1;
  }
  while (true) {
    long long int d = dijkstra(n, s, t);
    if (d > l) {
      cout << "NO" << endl;
      return 0;
    }
    if (d == l) break;
    if (fun(s, t, l - d) == false) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (i = 0; i < m; i++)
    cout << e[i].first << " " << e[i].second << " " << w[i] << endl;
  return 0;
}
