#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >,
               greater<pair<int, pair<int, int> > > >
    pq;
vector<int> g[1234];
int dist[1234][1234];
int special[1234][1234];
int previous[1234];
int n, m, l, s, t;
int s_to_t() {
  while (!pq.empty()) pq.pop();
  for (int i = 0; i < n; i++) {
    previous[i] = -1;
  }
  pq.push(make_pair(0, make_pair(s, 0)));
  while (!pq.empty()) {
    auto cur = pq.top();
    pq.pop();
    int len = cur.first;
    int curnode = cur.second.first;
    int prevnode = cur.second.second;
    if (previous[curnode] != -1) continue;
    previous[curnode] = prevnode;
    if (curnode == t) return len;
    for (auto child : g[curnode])
      if (len + dist[child][curnode] <= l)
        pq.push(
            make_pair(len + dist[child][curnode], make_pair(child, curnode)));
  }
  return 0;
}
void fail() {
  printf("NO\n");
  exit(0);
}
int main() {
  cin >> n >> m >> l >> s >> t;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back(v);
    g[v].push_back(u);
    if (w == 0) {
      special[v][u] = special[u][v] = true;
      w = 1;
    }
    dist[u][v] = dist[v][u] = w;
  }
  while (true) {
    int shortlen = s_to_t();
    if (shortlen == 0) fail();
    if (shortlen == l) break;
    int cur = t;
    int remain = l - shortlen;
    while (cur != s) {
      if (special[previous[cur]][cur]) {
        if (remain > 0) {
          dist[previous[cur]][cur] += remain;
          dist[cur][previous[cur]] += remain;
          remain = 0;
        }
        dist[previous[cur]][cur] *= -1;
        dist[cur][previous[cur]] *= -1;
      }
      cur = previous[cur];
    }
    if (remain > 0) fail();
    for (int i = 0; i < n; i++)
      for (auto child : g[i])
        if (special[i][child]) {
          if (dist[i][child] > 0)
            dist[i][child] = l + 1;
          else
            dist[i][child] *= -1;
        }
  }
  printf("YES\n");
  for (int i = 0; i < n; i++)
    for (auto j : g[i])
      if (i < j) {
        cout << i << " " << j << " " << dist[i][j] << endl;
      }
  return 0;
}
