#include <bits/stdc++.h>
const long double pi = 3.1415926535898;
const long long mod = 1e9 + 7;
using namespace std;
long long a[1001][1001];
vector<vector<long long>> v(1001);
long long dp[1001];
long long s, t, n;
long long dij() {
  for (long long i = 0; i < n; i++) {
    dp[i] = 1e15;
  }
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  dp[s] = 0;
  pq.push({0, s});
  while (pq.size()) {
    long long w = pq.top().first;
    long long x = pq.top().second;
    pq.pop();
    if (w > dp[x]) {
      continue;
    }
    for (auto i : v[x]) {
      if (dp[i] > dp[x] + a[x][i]) {
        dp[i] = dp[x] + a[x][i];
        pq.push({dp[i], i});
      }
    }
  }
  return dp[t];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long m, l, x, y, w;
  cin >> n >> m >> l >> s >> t;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      a[i][j] = 1e15;
    }
  }
  vector<pair<long long, long long>> e, ans;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y >> w;
    ans.push_back({x, y});
    v[x].push_back(y);
    v[y].push_back(x);
    if (w == 0) {
      e.push_back({x, y});
      w++;
    }
    a[x][y] = w;
    a[y][x] = w;
  }
  x = dij();
  y = l - x;
  for (auto i : e) {
    if (y < 0) {
      break;
    }
    a[i.first][i.second] += y;
    a[i.second][i.first] += y;
    x = dij();
    y = l - x;
    if (y == 0) {
      break;
    }
    a[i.first][i.second] = 1e15;
    a[i.second][i.first] = 1e15;
  }
  if (dij() != l) {
    cout << "NO";
    exit(0);
  }
  cout << "YES\n";
  for (auto i : ans) {
    cout << i.first << " " << i.second << " " << a[i.first][i.second] << "\n";
  }
  return 0;
}
