#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
const int maxn = 1010;
const int maxm = 10010;
struct edge {
  int v, w;
  edge(int v, int w) : v(v), w(w) {}
  edge() {}
};
int u[maxm];
int pu[maxm];
int v[maxm];
int pv[maxm];
int w[maxm];
bool flag[maxm];
vector<edge> E[maxn];
void addEdge(int u, int v, int w, int id) {
  pu[id] = E[u].size();
  pv[id] = E[v].size();
  E[u].push_back(edge(v, w));
  E[v].push_back(edge(u, w));
}
int n, m, l, s, t;
long long dist[maxn];
bool inque[maxn];
long long spfa() {
  for (int i = 0; i < n; i++) {
    dist[i] = INF;
  }
  dist[s] = 0;
  queue<int> que;
  que.push(s);
  inque[s] = 1;
  while (que.size()) {
    int cur = que.front();
    que.pop();
    inque[cur] = 0;
    for (int i = 0; i < (int)E[cur].size(); i++) {
      if (dist[E[cur][i].v] > dist[cur] + E[cur][i].w) {
        dist[E[cur][i].v] = dist[cur] + E[cur][i].w;
        if (!inque[E[cur][i].v]) {
          que.push(E[cur][i].v);
          inque[E[cur][i].v] = 1;
        }
      }
    }
  }
  return dist[t];
}
int main() {
  cin >> n >> m >> l >> s >> t;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &u[i], &v[i], &w[i]);
    if (w[i] == 0) {
      w[i] = 1;
      flag[i] = 1;
    }
    addEdge(u[i], v[i], w[i], i);
  }
  int id = 0;
  while (spfa() < l && id < m) {
    for (; id < m; id++) {
      if (flag[id]) {
        break;
      }
    }
    long long delta = l - dist[t];
    w[id] += delta;
    E[u[id]][pu[id]].w += delta;
    E[v[id]][pv[id]].w += delta;
    id++;
  }
  if (dist[t] == l) {
    puts("YES");
    for (int i = 0; i < m; i++) {
      printf("%d %d %d\n", u[i], v[i], w[i]);
    }
  } else {
    puts("NO");
  }
  return 0;
}
