#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 1e15;
long long int n, m, L, second, t, u, v, w;
long long int dist[1011];
int pa[1011];
vector<pair<long long int, long long int> > g[1011];
long long int add[1011][1011];
class comp {
 public:
  bool operator()(pair<pair<long long int, long long int>, long long int> a,
                  pair<pair<long long int, long long int>, long long int> b) {
    return a.first.first > b.first.first;
  }
};
long long int dj(bool flag = 0) {
  priority_queue<
      pair<pair<long long int, long long int>, long long int>,
      vector<pair<pair<long long int, long long int>, long long int> >, comp>
      pq;
  for (int i = 0; i < n; i++) {
    dist[i] = INF;
  }
  pq.push(make_pair(make_pair(0, second), -1));
  pair<pair<long long int, long long int>, long long int> x;
  while (pq.size() > 0) {
    x = pq.top();
    pq.pop();
    v = x.first.second;
    if (dist[v] < x.first.first) continue;
    dist[v] = x.first.first;
    pa[v] = x.second;
    if (v == t) break;
    for (int i = 0; i < g[v].size(); i++) {
      u = g[v][i].first;
      w = g[v][i].second;
      w += add[v][u];
      if (w == 0 and flag) continue;
      if (dist[u] > dist[v] + w) {
        dist[u] = dist[v] + w;
        pq.push(make_pair(make_pair(dist[v] + w, u), v));
      }
    }
  }
  return dist[t];
}
bool erased[1011][1011];
int main() {
  cin >> n >> m >> L >> second >> t;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
    if (w == 0) {
      erased[u][v] = erased[v][u] = 1;
    }
  }
  if (dj(1) < L) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if (g[i][j].second == 0) g[i][j].second = 1;
    }
  }
  if (dj() > L) {
    cout << "NO";
    return 0;
  }
  for (int j = 0; j < m; j++) {
    if (dj() == L) break;
    int cur = t;
    while (pa[cur] != -1) {
      if (erased[cur][pa[cur]]) {
        u = cur;
        v = pa[cur];
        add[v][u] += L - dist[t];
        add[u][v] += L - dist[t];
        break;
      }
      cur = pa[cur];
    }
  }
  if (dj() != L) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if (g[i][j].first > i) {
        cout << i << " " << g[i][j].first << " "
             << g[i][j].second + add[i][g[i][j].first] << "\n";
      }
    }
  }
}
