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 i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0, REP_N_ = (n); i < REP_N_; ++i)
#define ALL(x) std::begin(x), std::end(x)

template <class T>
inline int ssize(const T &a) {
  return (int)std::size(a);
}
template <class T>
inline bool chmax(T &a, T b) {
  return a < b and ((a = std::move(b)), true);
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b and ((a = std::move(b)), true);
}

template <typename T>
using V = std::vector<T>;

template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (auto &x : a) is >> x;
  return is;
}
template <typename Container>
std::ostream &pprint(const Container &a, std::string_view sep = " ",
                     std::string_view ends = "\n", std::ostream *os = nullptr) {
  if (os == nullptr) os = &std::cout;
  auto b = std::begin(a), e = std::end(a);
  for (auto it = std::begin(a); it != e; ++it) {
    if (it != b) *os << sep;
    *os << *it;
  }
  return *os << ends;
}
template <typename T, typename = void>
struct is_iterable : std::false_type {};
template <typename T>
struct is_iterable<T, std::void_t<decltype(std::begin(std::declval<T>())),
                                  decltype(std::end(std::declval<T>()))>>
    : std::true_type {};

template <typename T, typename = std::enable_if_t<
                          is_iterable<T>::value &&
                          !std::is_same<T, std::string_view>::value &&
                          !std::is_same<T, std::string>::value>>
std::ostream &operator<<(std::ostream &os, const T &a) {
  return pprint(a, ", ", "", &(os << "{")) << "}";
}
template <typename T, typename U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &a) {
  return os << "(" << a.first << ", " << a.second << ")";
}

#ifdef ENABLE_DEBUG
template <typename T>
void pdebug(const T &value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void pdebug(const T &value, const Ts &...args) {
  pdebug(value);
  std::cerr << ", ";
  pdebug(args...);
}
#define DEBUG(...)                                   \
  do {                                               \
    std::cerr << " \033[33m (L" << __LINE__ << ") "; \
    std::cerr << #__VA_ARGS__ << ":\033[0m ";        \
    pdebug(__VA_ARGS__);                             \
    std::cerr << std::endl;                          \
  } while (0)
#else
#define pdebug(...)
#define DEBUG(...)
#endif

using namespace std;

const i64 INF = 1e18;

template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

struct Edge {
  i64 cost;
  int to;
  int from;
};

struct State {
  i64 cost;
  int node;
  //...
};
bool operator>(const State &x, const State &y) { return x.cost > y.cost; }

// Returns min distance from the source node to each node (if exists).
pair<V<i64>, V<int>> dijkstra(const std::vector<std::vector<Edge>> &g,
                              int source, int sink, i64 erased_cost) {
  const int n = g.size();
  std::vector<i64> mincost(n, INF);
  mincost[source] = 0LL;
  V<int> parent(n, -1);
  MinHeap<State> que;
  que.push({0LL, source});
  while (not que.empty()) {
    State cur = std::move(que.top());
    que.pop();
    if (cur.cost != mincost[cur.node]) {
      continue;
    }
    if (cur.node == sink) break;
    for (const auto &e : g[cur.node]) {
      i64 new_cost = cur.cost;
      if (e.cost == 0) {
        new_cost += erased_cost;
      } else {
        new_cost += e.cost;
      }
      if (mincost[e.to] > new_cost) {
        mincost[e.to] = new_cost;
        parent[e.to] = cur.node;
        que.push({new_cost, e.to});
      }
    }
  }
  return {mincost, parent};
}

optional<V<Edge>> solve() {
  i64 n, m, L, s, t;
  cin >> n >> m >> L >> s >> t;
  V<V<Edge>> g(n);
  V<Edge> edges(m);
  map<pair<int, int>, int> edge_id;
  REP(i, m) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back({w, v, u});
    g[v].push_back({w, u, v});
    edges[i] = {w, v, u};
    edge_id[{u, v}] = edge_id[{v, u}] = i;
  }

  auto [res2, _] = dijkstra(g, s, t, INF);
  DEBUG(res2);
  if (res2[t] < L) {
    return nullopt;
  }
  if (res2[t] == L) {
    for (auto &e : edges) {
      if (e.cost == 0) {
        e.cost = 1e18;
      }
    }
    return edges;
  }

  auto [res1, par] = dijkstra(g, s, t, 0);
  DEBUG(res1);
  int num_erased = 0;
  for (int v = t; v >= 0; v = par[v]) {
    int p = par[v];
    if (p < 0) break;
    int e = edge_id[{v, p}];
    if (edges[e].cost == 0) ++num_erased;
    if (p == s) break;
  }
  if (res1[t] + num_erased > L) {
    return nullopt;
  }
  if (num_erased == 0) {
    return nullopt;
  }
  i64 tbf = L - res1[t];
  i64 tbfa = tbf / num_erased;
  DEBUG(num_erased, tbf, tbfa);
  int done_cnt = 0;
  for (int v = t; v >= 0; v = par[v]) {
    int p = par[v];
    if (p < 0) break;
    int e = edge_id[{v, p}];
    if (edges[e].cost == 0) {
      ++done_cnt;
      if (done_cnt == num_erased) {
        edges[e].cost = tbf;
      } else {
        edges[e].cost = tbfa;
        tbf -= tbfa;
      }
    }
    if (p == s) break;
  }
  for (auto &e : edges) {
    if (e.cost == 0) {
      e.cost = 1e18;
    }
  }
  return edges;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  auto res = solve();
  if (not res.has_value()) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    for (auto &e : res.value()) {
      cout << e.from << ' ' << e.to << ' ' << e.cost << '\n';
    }
  }
}