#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
vector<int> G[maxn];
int n;
const int INF = 1 << 30;
void init(int n) {
  for (int i = 0; i < n; ++i) {
    G[i].clear();
  }
}
void AddEdge(int x, int y) {
  G[x].push_back(y);
  G[y].push_back(x);
}
int x[maxn * 10], y[maxn * 10];
int dis[maxn][maxn];
int d1[maxn], d2[maxn];
void bfs1(int t, int L) {
  memset(d1, 0, sizeof(d1));
  priority_queue<pair<int, int> > Q;
  d1[t] = L;
  Q.push(pair<int, int>(L, t));
  while (Q.size()) {
    pair<int, int> tp = Q.top();
    Q.pop();
    int u = tp.second;
    int c = tp.first;
    if (c != d1[u]) continue;
    for (int i = 0; i < G[u].size(); ++i) {
      int v = G[u][i];
      int cc = dis[v][u];
      if (!cc)
        continue;
      else if (c - cc > d1[v]) {
        d1[v] = c - cc;
        Q.push(pair<int, int>(d1[v], v));
      }
    }
  }
}
bool bfs2(int s, int t, int L) {
  fill(d2, d2 + n, INF);
  d2[s] = 0;
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      Q;
  Q.push(pair<int, int>(0, s));
  while (Q.size()) {
    pair<int, int> tp = Q.top();
    Q.pop();
    int u = tp.second;
    int c = tp.first;
    if (d2[u] != c) continue;
    if (c < d1[u]) return false;
    for (int i = 0; i < G[u].size(); ++i) {
      int v = G[u][i];
      int cc = dis[v][u];
      if (cc == 0) {
        cc = max(d1[v] - c, 1);
        dis[v][u] = dis[u][v] = cc;
      }
      int tmp = c + cc;
      if (tmp < d2[v]) {
        d2[v] = tmp;
        Q.push(pair<int, int>(tmp, v));
      }
    }
  }
  return d2[t] == L;
}
int main() {
  int m, L, s, t;
  while (~scanf("%d%d%d%d%d", &n, &m, &L, &s, &t)) {
    init(n);
    for (int i = 0; i < m; ++i) {
      int c;
      scanf("%d%d%d", x + i, y + i, &c);
      AddEdge(x[i], y[i]);
      dis[x[i]][y[i]] = dis[y[i]][x[i]] = c;
    }
    bfs1(t, L);
    if (bfs2(s, t, L)) {
      puts("YES");
      for (int i = 0; i < m; ++i) {
        printf("%d %d %d\n", x[i], y[i], dis[x[i]][y[i]] ? dis[x[i]][y[i]] : 1);
      }
    } else {
      puts("NO");
    }
  }
  return 0;
}
