#include <bits/stdc++.h>
using namespace std;
long long n, m, l, s, t, visited[1010], dist[1010], par[1010];
set<pair<int, int> > df;
vector<pair<long long, pair<long long, long long> > > graph[1010];
long long dijkstra() {
  for (int i = 0; i < n; i++) {
    dist[i] = 1e10;
    visited[i] = 0;
    par[i] = -1;
  }
  dist[s] = 0;
  set<pair<long long, long long> > pq;
  pq.insert(make_pair(dist[s], s));
  while (pq.size()) {
    pair<long long, long long> x = *pq.begin();
    pq.erase(pq.begin());
    long long vert = x.second;
    if (vert == t) break;
    visited[vert] = 1;
    for (int i = 0; i < graph[vert].size(); i++) {
      pair<long long, pair<long long, long long> > temp = graph[vert][i];
      if (!visited[temp.first]) {
        pq.erase(make_pair(dist[temp.first], temp.first));
        dist[temp.first] =
            min(dist[temp.first], dist[vert] + temp.second.first);
        if (dist[temp.first] == dist[vert] + temp.second.first)
          par[temp.first] = vert;
        pq.insert(make_pair(dist[temp.first], temp.first));
      }
    }
  }
  return dist[t];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> l >> s >> t;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    graph[a].push_back(make_pair(b, make_pair(max(1, c), (c == 0 ? 1 : 0))));
    graph[b].push_back(make_pair(a, make_pair(max(1, c), (c == 0 ? 1 : 0))));
    df.insert(make_pair(a, b));
  }
  long long val = dijkstra();
  if (val > l) {
    cout << "NO\n";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      if (graph[i][j].second.second) graph[i][j].second.first = 1e10;
    }
  }
  int cur = t;
  memset(visited, 0, sizeof(visited));
  while (cur != -1) {
    visited[cur] = 1;
    cur = par[cur];
  }
  cur = s;
  while (1) {
    for (int i = 0; i < graph[cur].size(); i++) {
      pair<long long, pair<long long, long long> > temp = graph[cur][i];
      if (visited[temp.first] && par[temp.first] == cur) {
        if (temp.second.second) {
          graph[cur][i].second.first = 1;
          for (int j = 0; j < graph[temp.first].size(); j++) {
            if (graph[temp.first][j].first == cur) {
              graph[temp.first][j].second.first = 1;
            }
          }
        }
        cur = temp.first;
        break;
      }
    }
    if (cur == t) break;
  }
  val = dijkstra();
  while (val != l) {
    memset(visited, 0, sizeof(visited));
    cur = t;
    while (cur != -1) {
      visited[cur] = 1;
      cur = par[cur];
    }
    cur = s;
    int mk = 0;
    while (1) {
      for (int i = 0; i < graph[cur].size(); i++) {
        pair<long long, pair<long long, long long> > temp = graph[cur][i];
        if (visited[temp.first] && par[temp.first] == cur) {
          if (temp.second.second == 1) {
            for (int j = 0; j < graph[temp.first].size(); j++) {
              if (graph[temp.first][j].first == cur) {
                graph[temp.first][j].second.first += l - val;
              }
            }
            graph[cur][i].second.first += l - val;
            mk = 1;
          }
          cur = temp.first;
          break;
        }
      }
      if (mk) break;
      if (cur == t) {
        if (val != l) {
          cout << "NO\n";
          return 0;
        }
        break;
      }
    }
    val = dijkstra();
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < graph[i].size(); j++) {
      pair<long long, pair<long long, long long> > temp = graph[i][j];
      if (df.find(make_pair(i, temp.first)) != df.end()) {
        cout << i << " " << temp.first << " " << temp.second.first << '\n';
      }
    }
  }
}
