7 9 999999999 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 7 9 320 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 4 5 7 0 3
0 1 0
1 2 3
2 3 0
0 2 5
1 3 5
 8 9 10 1 0
1 2 1
2 4 1
1 3 0
3 4 0
4 5 0
5 6 1
6 0 1
5 7 0
7 0 0
 4 4 14 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 5 6 1000000000 0 4
0 1 1
2 0 2
3 0 3
4 1 0
4 2 0
3 4 0
 4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
 4 4 2 1 3
1 3 13
2 3 0
2 0 0
1 0 0
 5 5 2 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 5 5 3 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 4 4 8 1 3
1 3 13
2 3 0
2 0 0
1 0 6
 1000 1 1000000000 998 0
0 999 0
 5 5 1 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 100 1 123456 99 0
0 99 123456
 4 4 13 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 7 9 319 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 1000 1 5 999 0
0 999 0

YES
0 1 1
1 2 999999996
2 3 999999997
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 YES
0 1 1
1 2 199
2 3 318
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 1 3
1 2 3
2 3 2
0 2 5
1 3 5
 YES
1 2 1
2 4 1
1 3 1
3 4 1
4 5 6
5 6 1
6 0 1
5 7 1
7 0 1
 NO YES
0 1 1
2 0 2
3 0 3
4 1 999999999
4 2 999999998
3 4 999999997
 NO NO YES
0 1 1
1 2 1
0 4 1
4 3 1
3 2 1
 NO YES
1 3 13
2 3 1
2 0 1
1 0 6
 NO NO YES
0 99 123456
 YES
1 3 13
2 3 1
2 0 1
1 0 12
 YES
0 1 1
1 2 198
2 3 317
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 999 5

#include <bits/stdc++.h>
using namespace std;
const long long INF = pow(10ll, 18);
struct Edge {
  long long u, v, w;
  Edge(long long u0, long long v0, long long w0) : u(u0), v(v0), w(w0) {}
};
long long other_node(long long u, const Edge &edge) {
  return edge.u == u ? edge.v : edge.u;
}
unordered_map<long long, bool> missing_edge;
vector<Edge> edges;
vector<vector<long long>> graph;
long long L;
long long start, target;
void print_graph(const vector<Edge> &edges) {
  for (const auto &p : edges) {
    cout << p.u << " " << p.v << " " << p.w << endl;
  }
}
void shortest_path(vector<long long> &path, long long &len) {
  long long n = graph.size();
  vector<long long> dist(n, INF);
  vector<long long> prev(n, -1);
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      que;
  dist[start] = 0;
  que.push({0, start});
  while (!que.empty()) {
    auto p = que.top();
    que.pop();
    long long d = p.first, u = p.second;
    if (d > dist[u]) {
      continue;
    }
    for (auto edge_ind : graph[u]) {
      long long v = other_node(u, edges[edge_ind]), w = edges[edge_ind].w;
      if (w != INF && dist[u] + w < dist[v]) {
        dist[v] = dist[u] + w;
        prev[v] = edge_ind;
        que.push({dist[v], v});
      }
    }
  }
  path.clear();
  len = dist[target];
  if (prev[target] == -1) {
    return;
  }
  long long cur = target;
  while (prev[cur] != -1) {
    path.push_back(prev[cur]);
    cur = other_node(cur, edges[prev[cur]]);
  }
}
void solve() {
  for (auto &p : missing_edge) {
    edges[p.first].w = INF;
  }
  vector<long long> path;
  long long len;
  shortest_path(path, len);
  if (len < L) {
    cout << "NO" << endl;
    return;
  }
  if (len == L) {
    cout << "YES" << endl;
    print_graph(edges);
    return;
  }
  for (auto &p : missing_edge) {
    edges[p.first].w = 1;
  }
  shortest_path(path, len);
  if (len > L) {
    cout << "NO" << endl;
    return;
  }
  if (len < L) {
    bool f = true;
    for (auto edge_ind : path) {
      if (missing_edge.find(edge_ind) != missing_edge.end()) {
        missing_edge[edge_ind] = true;
        if (f) {
          edges[edge_ind].w += L - len;
          f = false;
        }
      }
    }
    for (auto &p : missing_edge) {
      if (!p.second) {
        edges[p.first].w = INF;
      }
    }
  }
  cout << "YES" << endl;
  print_graph(edges);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (true) {
    long long n, m;
    cin >> n >> m >> L >> start >> target;
    if (!cin) {
      break;
    }
    graph.assign(n, {});
    edges.clear();
    edges.reserve(m);
    missing_edge.clear();
    for (long long i = 0; i < m; ++i) {
      long long u, v, w;
      cin >> u >> v >> w;
      edges.push_back(Edge(u, v, w));
      graph[u].push_back(i);
      graph[v].push_back(i);
      if (w == 0) {
        missing_edge[i] = false;
      }
    }
    solve();
  }
  return 0;
}
