#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const long long INF = 0x3f3f3f3f;
const long long INFF = 1e17;
const long long mod = 10000007;
const long long N = 1010;
int n, m, l, s, t;
int ed[10010][3];
vector<pair<int, int> > maps[1010];
long long dist[1010];
void dij() {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      pq;
  pq.push(make_pair(0, s));
  fill(dist, dist + n, INFF);
  dist[s] = 0;
  while (!pq.empty()) {
    pair<long long, int> now;
    now = pq.top();
    pq.pop();
    if (dist[now.second] < now.first) continue;
    for (int i = 0; i < maps[now.second].size(); i++) {
      pair<int, int> temp = maps[now.second][i];
      if (dist[temp.first] > dist[now.second] + temp.second) {
        dist[temp.first] = dist[now.second] + temp.second;
        pq.push(make_pair(dist[temp.first], temp.first));
      }
    }
  }
}
int main() {
  while (~scanf("%d%d%d%d%d", &n, &m, &l, &s, &t)) {
    for (int i = 0; i < m; i++) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      if (w) {
        maps[u].push_back(make_pair(v, w));
        maps[v].push_back(make_pair(u, w));
      }
      ed[i][0] = u;
      ed[i][1] = v;
      ed[i][2] = w;
    }
    dij();
    if (dist[t] < l)
      printf("NO\n");
    else {
      for (int i = 0; i < m; i++) {
        int u, v, w;
        u = ed[i][0];
        v = ed[i][1];
        w = ed[i][2];
        if (w) continue;
        w = ed[i][2] = 1;
        maps[u].push_back(make_pair(v, w));
        maps[v].push_back(make_pair(u, w));
        dij();
        if (dist[t] < l) {
          ed[i][2] = l - dist[t] + 1;
          maps[u][maps[u].size() - 1].second = ed[i][2];
          maps[v][maps[v].size() - 1].second = ed[i][2];
        }
      }
      if (dist[t] > l)
        printf("NO\n");
      else {
        printf("YES\n");
        for (int i = 0; i < m; i++) {
          printf("%d %d %d\n", ed[i][0], ed[i][1], ed[i][2]);
        }
      }
    }
  }
  return 0;
}
