#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
struct Edge {
  int v, cost, i;
};
vector<Edge> adj[N];
Edge parent[N];
long long dijkstra(int source, int destination) {
  long long dist[N];
  memset(parent, -1, sizeof parent);
  memset(dist, 0x3f, sizeof dist);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      q;
  q.push({0, source});
  while (!q.empty()) {
    auto cur = q.top();
    q.pop();
    long long cost = cur.first;
    int node = cur.second;
    if (dist[node] < cost) continue;
    dist[node] = cost;
    for (auto child : adj[node]) {
      if (dist[child.v] > cost + child.cost) {
        parent[child.v] = {node, child.cost, child.i};
        dist[child.v] = cost + child.cost;
        q.push({cost + child.cost, child.v});
      }
    }
  }
  return dist[destination];
}
int u[N], v[N], c[N];
bool erased[N];
int zeros(int t) {
  int node = t;
  int ret = 0;
  while (~parent[node].v) {
    if (erased[parent[node].i]) ++ret;
    node = parent[node].v;
  }
  return ret;
}
int main() {
  int n, m, l, s, t;
  scanf("%d %d %d %d %d", &n, &m, &l, &s, &t);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", u + i, v + i, c + i);
    erased[i] = c[i] == 0;
    if (!c[i]) c[i] = 1;
    adj[u[i]].push_back({v[i], c[i], i});
    adj[v[i]].push_back({u[i], c[i], i});
  }
  long long dis;
  int temp = 1e3;
  while (temp--) {
    dis = dijkstra(s, t);
    if (dis == l) break;
    if (dis > l) {
      puts("NO");
      return 0;
    }
    int node = t;
    bool first = false;
    bool leave[N] = {};
    while (~parent[node].v) {
      if (erased[parent[node].i]) {
        leave[parent[node].i] = true;
        if (!first++)
          c[parent[node].i] = max(1, c[parent[node].i] + l - (int)dis);
      }
      node = parent[node].v;
    }
    for (int i = 0; i < m; ++i)
      if (erased[i] && !leave[i]) c[i] = 2e9;
    for (int i = 0; i < n; ++i)
      for (auto &child : adj[i]) child.cost = c[child.i];
  }
  if (dis != l) {
    puts("NO");
  } else {
    puts("YES");
    for (int i = 0; i < m; ++i) printf("%d %d %d\n", u[i], v[i], c[i]);
  }
  return 0;
}
