#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) {
    for (auto edge_ind : path) {
      if (missing_edge.find(edge_ind) != missing_edge.end()) {
        missing_edge[edge_ind] = true;
      }
    }
    for (auto &p : missing_edge) {
      if (!p.second) {
        edges[p.first].w = INF;
      }
    }
    while (len < L) {
      for (auto edge_ind : path) {
        if (missing_edge.find(edge_ind) != missing_edge.end()) {
          edges[edge_ind].w += L - len;
          break;
        }
      }
      shortest_path(path, len);
    }
  }
  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;
}
