#include <bits/stdc++.h>
using namespace std;
long long dis[11111];
int vis[11111];
vector<int> adj[1111];
vector<long long> cost[1111];
vector<int> path;
map<pair<int, int>, int> give;
void bfs(int start, int n) {
  for (int i = 0; i < n; i++) dis[i] = 1e10;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      Q;
  Q.push(make_pair(0, start));
  dis[start] = 0;
  while (!Q.empty()) {
    int p = Q.top().second;
    Q.pop();
    for (int i = 0; i < adj[p].size(); i++) {
      int c = adj[p][i];
      if (dis[c] > dis[p] + cost[p][i]) {
        dis[c] = dis[p] + cost[p][i];
        Q.push(make_pair(dis[c], c));
      }
    }
  }
}
int main() {
  int v, e, L, s, t;
  cin >> v >> e >> L;
  cin >> s >> t;
  int a, b, w;
  int ar[e][3];
  int E = e;
  int j = 0;
  vector<pair<int, int> > p;
  while (e--) {
    cin >> a >> b >> w;
    ar[j][0] = a, ar[j][1] = b, ar[j][2] = w;
    if (!w) {
      p.push_back(make_pair(a, b));
    } else {
      adj[a].push_back(b);
      cost[a].push_back(w);
      adj[b].push_back(a);
      cost[b].push_back(w);
    }
    j++;
  }
  bfs(s, v);
  if (dis[t] < L) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < p.size(); i++) {
    int a = p[i].first, b = p[i].second;
    adj[a].push_back(b);
    cost[a].push_back(1);
    adj[b].push_back(a);
    cost[b].push_back(1);
    bfs(s, v);
    long long Dis = dis[t];
    if (dis[t] < L) {
      cost[a].pop_back();
      cost[a].push_back(L - dis[t] + 1);
      cost[b].pop_back();
      cost[b].push_back(L - dis[t] + 1);
    }
  }
  bfs(s, v);
  if (dis[t] > L) {
    cout << "NO";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i <= v; i++) {
    for (int j = 0; j < adj[i].size(); j++) {
      if (adj[i][j] < i) continue;
      cout << i << " " << adj[i][j] << " " << cost[i][j] << "\n";
    }
  }
}
