#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 3;
vector<int> G[MAXN];
int n, m, l;
long long d[MAXN];
int father[MAXN];
int vis[MAXN][MAXN], cost[MAXN][MAXN], valid[MAXN][MAXN], cam[MAXN][MAXN];
int s, t;
long long dijk() {
  priority_queue<pair<int, int> > pq;
  pq.push({0, s});
  d[s] = 0;
  father[s] = -1;
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (u == t) return d[u];
    for (auto v : G[u]) {
      int c = cost[u][v];
      if (!c) continue;
      if (d[v] == -1 || d[v] > d[u] + c) {
        d[v] = d[u] + c;
        father[v] = u;
        pq.push({-d[v], v});
      }
    }
  }
  return l + 1;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d %d", &l, &s, &t);
  for (int i = (int)0; i < (int)m; i++) {
    int u, v, w;
    scanf("%d %d", &u, &v);
    scanf("%d", &w);
    G[u].push_back(v);
    G[v].push_back(u);
    cost[u][v] = w;
    cost[v][u] = w;
  }
  memset(d, -1, sizeof(d));
  long long ans = dijk();
  if (ans < l) {
    printf("NO\n");
    return 0;
  }
  for (int u = (int)0; u < (int)n; u++) {
    for (int j = (int)0; j < (int)G[u].size(); j++) {
      int v = G[u][j];
      if (cost[u][v] == 0) cost[u][v] = 1, valid[u][v] = 1;
    }
  }
  memset(d, -1, sizeof(d));
  long long ans1 = dijk();
  if (ans1 > l) {
    printf("NO\n");
    return 0;
  }
  vector<pair<int, int> > vec;
  int curr = t;
  while (curr != -1) {
    int v = father[curr];
    if (valid[curr][v])
      cam[curr][v] = 1, cam[v][curr] = 1, vec.push_back({curr, v});
    curr = v;
  }
  for (int u = (int)0; u < (int)n; u++)
    for (int v = (int)0; v < (int)n; v++)
      if (valid[u][v] && !cam[u][v]) cost[u][v] = l + 1;
  int p = 0;
  ans = ans1;
  while (p < vec.size()) {
    int u = vec[p].first, v = vec[p].second;
    int lo = 0, hi = l;
    while (lo < hi) {
      int mid = (lo + hi + 1) / 2;
      memset(d, -1, sizeof(d));
      cost[u][v] += mid;
      cost[v][u] += mid;
      long long curr = dijk();
      if (curr == l) {
        cost[u][v] -= mid;
        cost[v][u] -= mid;
        lo = mid;
        break;
      } else if (curr != ans + mid || curr > l)
        hi = mid - 1;
      else
        lo = mid;
      cost[u][v] -= mid;
      cost[v][u] -= mid;
    }
    cost[u][v] += lo;
    cost[v][u] += lo;
    p++;
    memset(d, -1, sizeof(d));
    ans = dijk();
    if (ans == l) break;
  }
  printf("YES\n");
  for (int u = (int)0; u < (int)n; u++) {
    for (auto v : G[u]) {
      if (vis[u][v]) continue;
      vis[u][v] = 1;
      vis[v][u] = 1;
      int w = cost[u][v];
      printf("%d %d %d\n", u, v, w);
    }
  }
}
