#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3;
const int MAXM = 1e4;
const long long oo = 1e12;
int n, m, s, t, u[MAXM], v[MAXM], c;
pair<int, int> tra[MAX];
long long L, len, dis[MAX], res[MAXM];
struct Node {
  int point, id;
  bool fixed;
  Node(const int& point, const int& id, const bool& fixed)
      : point(point), id(id), fixed(fixed) {}
};
vector<Node> adj[MAX];
queue<int> que;
bool fr[MAX];
long long dijkstra() {
  for (int i = 0; i < n; ++i) dis[i] = oo;
  dis[s] = 0;
  fr[s] = true;
  que.push(s);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    fr[u] = false;
    int i = 0;
    for (Node& node : adj[u]) {
      if (dis[node.point] > dis[u] + res[node.id]) {
        dis[node.point] = dis[u] + res[node.id];
        tra[node.point] = pair<int, int>(u, i);
        if (!fr[node.point]) {
          fr[node.point] = true;
          que.push(node.point);
        }
      }
      ++i;
    }
  }
  return dis[t];
}
int main() {
  scanf("%d %d %lld %d %d", &n, &m, &L, &s, &t);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", u + i, v + i, &c);
    bool fixed = (c > 0);
    if (c == 0) c = 1;
    res[i] = c;
    adj[u[i]].push_back(Node(v[i], i, fixed));
    adj[v[i]].push_back(Node(u[i], i, fixed));
  }
  for (int i = 0; i < n; ++i) dis[i] = oo;
  dis[s] = 0;
  fr[s] = true;
  que.push(s);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    fr[u] = false;
    for (Node& node : adj[u])
      if (node.fixed)
        if (dis[node.point] > dis[u] + res[node.id]) {
          dis[node.point] = dis[u] + res[node.id];
          if (!fr[node.point]) {
            fr[node.point] = true;
            que.push(node.point);
          }
        }
  }
  if (dis[t] < L || dijkstra() > L) {
    printf("NO");
    return 0;
  }
  if (dis[t] == L) {
    printf("YES\n");
    for (int i = 0; i < m; ++i) {
      if (res[i] == 0) res[i] = oo;
      printf("%d %d %lld\n", u[i], v[i], res[i]);
    }
    return 0;
  }
  for (int i = 0; i < m; ++i)
    if (res[i] == 0) res[i] = 1;
  while ((len = dijkstra()) < L) {
    int u = t, dir;
    while (1) {
      dir = tra[u].second;
      u = tra[u].first;
      if (!adj[u][dir].fixed) {
        res[adj[u][dir].id] += L - len;
        break;
      }
    }
  }
  printf("YES\n");
  for (int i = 0; i < m; ++i) printf("%d %d %lld\n", u[i], v[i], res[i]);
  return 0;
}
