#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e4;
vector<pair<int, int> > adj[MAX];
map<pair<int, int>, int> M;
int n, m, s, t;
long long L;
long long dis1[MAX], dis2[MAX];
set<pair<int, int> > BAD;
bool visited[MAX];
void dijkstra(int t) {
  fill(dis1, dis1 + n + 2, 1000000000000000LL);
  dis1[t] = 0;
  priority_queue<pair<long long, int> > q;
  q.push(make_pair(0, t));
  while (!q.empty()) {
    pair<long long, int> temp = q.top();
    q.pop();
    int u = temp.second;
    long long d = -temp.first;
    for (auto j : adj[u])
      if (dis1[j.second] > j.first + dis1[u]) {
        dis1[j.second] = j.first + dis1[u];
        q.push(make_pair(-dis1[j.second], j.second));
      }
  }
}
bool func() {
  dijkstra(t);
  fill(dis2, dis2 + n + 2, 1000000000000000LL);
  dis2[s] = 0;
  priority_queue<pair<long long, int> > q;
  q.push(make_pair(0, s));
  while (!q.empty()) {
    pair<long long, int> temp = q.top();
    q.pop();
    int u = temp.second;
    if (visited[u]) continue;
    visited[u] = true;
    long long d = -temp.first;
    for (auto j : adj[u]) {
      int v = j.second;
      long long w = j.first;
      if (visited[v]) continue;
      if (BAD.find(make_pair(min(u, v), max(u, v))) != BAD.end()) {
        M[make_pair(min(u, v), max(u, v))] = max(1LL, L - d - dis1[v]);
        w = max(1LL, L - d - dis1[v]);
      }
      if (dis2[v] > dis2[u] + w) {
        dis2[v] = dis2[u] + w;
        q.push(make_pair(-dis2[v], v));
      }
    }
  }
  return dis2[t] == L;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> L >> s >> t;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    if (u > v) swap(u, v);
    adj[u].push_back(make_pair(max(1, w), v));
    adj[v].push_back(make_pair(max(1, w), u));
    if (w == 0) BAD.insert(make_pair(u, v));
    M[make_pair(u, v)] = w;
  }
  if (func()) {
    cout << "YES" << endl;
    for (auto j : M)
      cout << j.first.first << " " << j.first.second << " "
           << (j.second == 0 ? 1000000000000000LL : j.second) << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
