#include <bits/stdc++.h>
using namespace std;
int N, M, L, S, T;
vector<int> parent(1005, -1);
vector<vector<int>> adjList(1005);
vector<long long> dist(1005, -1);
vector<vector<long long>> adjMatrix(1005, vector<long long>(1005, -1));
vector<pair<int, int>> edges;
void dijkstra(int S, int T, bool useZero) {
  fill(dist.begin(), dist.end(), -1);
  fill(parent.begin(), parent.end(), -1);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      pq;
  dist[S] = 0;
  pq.push(pair<long long, int>(0, S));
  while (!pq.empty()) {
    pair<long long, int> front = pq.top();
    pq.pop();
    long long d = front.first;
    int u = front.second;
    if (d > dist[u]) continue;
    for (int v : adjList[u]) {
      long long w;
      if (adjMatrix[u][v] == 0) {
        if (!useZero) continue;
        w = 1;
      } else {
        w = adjMatrix[u][v];
      }
      if (dist[v] == -1 || dist[u] + w < dist[v]) {
        dist[v] = dist[u] + w;
        parent[v] = u;
        pq.push(pair<long long, int>(dist[v], v));
      }
    }
  }
}
void solve() {
  cin >> N >> M >> L >> S >> T;
  for (int i = 0; i < M; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
    adjMatrix[u][v] = w;
    adjMatrix[v][u] = w;
    edges.push_back({u, v});
  }
  dijkstra(S, T, false);
  if (dist[T] < L && dist[T] != -1) {
    cout << "NO" << endl;
    return;
  } else if (dist[T] == L) {
    cout << "YES" << endl;
    for (pair<int, int> edge : edges) {
      int u, v;
      u = edge.first;
      v = edge.second;
      if (adjMatrix[u][v] == 0) {
        adjMatrix[u][v] = 1;
      }
      cout << u << " " << v << " " << adjMatrix[u][v] << endl;
    }
    return;
  }
  dijkstra(S, T, true);
  if (dist[T] == -1 || dist[T] > L) {
    cout << "NO" << endl;
    return;
  }
  while (dist[T] < L) {
    long long remaining = L - dist[T];
    int cur = T;
    while (cur != S) {
      int u, v;
      v = cur;
      u = parent[cur];
      if (adjMatrix[u][v] == 0) {
        adjMatrix[u][v] = remaining + 1;
        adjMatrix[v][u] = remaining + 1;
        break;
      }
      cur = parent[cur];
    }
    dijkstra(S, T, true);
  }
  if (dist[T] != L) {
    cout << "NO" << endl;
    return;
  }
  cout << "YES" << endl;
  for (pair<int, int> edge : edges) {
    int u, v;
    u = edge.first;
    v = edge.second;
    if (adjMatrix[u][v] == 0) {
      adjMatrix[u][v] = 1;
    }
    cout << u << " " << v << " " << adjMatrix[u][v] << endl;
  }
}
int main() {
  solve();
  return 0;
}
