#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int M = 10010;
const long long oo = 0x3f3f3f3f3f3f3f3fll;
int n, m, src, dst;
int uu[M * 2], vv[M * 2], head[N], dest[M * 2], wght[M * 2], last[M * 2], etot;
bool done[N];
long long dis[N];
long long L;
int qu[M], bg, ed;
void adde(int u, int v, int w) {
  dest[etot] = v;
  last[etot] = head[u];
  wght[etot] = w;
  uu[etot] = u;
  vv[etot] = v;
  head[u] = etot;
  etot++;
}
long long dijkstra(int src, int dst) {
  for (int i = 0; i < n; i++) {
    done[i] = false;
    dis[i] = oo;
  }
  priority_queue<pair<long long, int> > qu;
  dis[src] = 0;
  qu.push(make_pair(-dis[src], src));
  while (!qu.empty()) {
    int u = qu.top().second;
    qu.pop();
    if (done[u]) continue;
    done[u] = true;
    if (u == dst) return dis[dst];
    for (int t = head[u]; t != -1; t = last[t]) {
      int v = dest[t], w = wght[t];
      if (done[v]) continue;
      if (dis[v] > dis[u] + w) {
        dis[v] = dis[u] + w;
        qu.push(make_pair(-dis[v], v));
      }
    }
  }
  return dis[dst];
}
int main() {
  cin >> n >> m >> L >> src >> dst;
  bg = 1;
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    if (w == 0) qu[++ed] = etot;
    adde(u, v, w);
    adde(v, u, w);
  }
  for (int i = bg; i <= ed; i++) {
    int e = qu[i];
    wght[e] = wght[e ^ 1] = 1e9;
  }
  if (dijkstra(src, dst) < L) {
    printf("NO\n");
  } else {
    if (ed == 0) {
      if (dijkstra(src, dst) == L) {
        printf("YES\n");
        for (int e = 0; e < etot; e += 2)
          cout << uu[e] << " " << vv[e] << " " << wght[e] << endl;
      } else {
        printf("NO\n");
      }
    } else {
      for (int i = bg; i <= ed; i++) {
        int e = qu[i];
        wght[e] = wght[e ^ 1] = 1;
        long long dist = dijkstra(src, dst);
        if (dist <= L) {
          wght[e] = wght[e ^ 1] = L - dist + 1;
          printf("YES\n");
          for (int e = 0; e < etot; e += 2) {
            cout << uu[e] << " " << vv[e] << " " << wght[e] << endl;
          }
          return 0;
        }
      }
      printf("NO\n");
    }
  }
}
