#include <bits/stdc++.h>
using namespace std;
void Read(int &n) {
  int sign = 1;
  n = 0;
  char c;
  do {
    c = getchar();
  } while (!isdigit(c) && c != '-');
  if (c == '-') {
    c = getchar();
    sign = -1;
  }
  do {
    n = n * 10 + c - 48;
    c = getchar();
  } while (isdigit(c));
  n *= sign;
}
void Read(long long &n) {
  int sign = 1;
  n = 0;
  char c;
  do {
    c = getchar();
  } while (!isdigit(c) && c != '-');
  if (c == '-') {
    c = getchar();
    sign = -1;
  }
  do {
    n = n * 10ll + c - 48;
    c = getchar();
  } while (isdigit(c));
  n *= sign;
}
void Write(int n) {
  if (n == 0)
    putchar('0');
  else if (n < 0)
    putchar('-'), n = -n;
  char C[30];
  int d = 0;
  while (n) {
    C[++d] = (n % 10) + 48;
    n /= 10;
  }
  for (int i = d; i >= 1; --i) putchar(C[i]);
}
void Write(long long n) {
  if (n == 0)
    putchar('0');
  else if (n < 0)
    putchar('-'), n = -n;
  char C[30];
  int d = 0;
  while (n) {
    C[++d] = (n % 10ll) + 48;
    n /= 10ll;
  }
  for (int i = d; i >= 1; --i) putchar(C[i]);
}
const int maxn = 1005;
const int maxm = 5e6 + 5;
const long long INFL = 1e18;
struct Edge {
  int u, v, w;
  Edge() {}
  Edge(int u, int v, int w) : u(u), v(v), w(w) {}
} E[maxm];
vector<pair<int, int> > adj[maxn];
int n, m, L, s, t;
int T[maxn];
long long d[maxn];
long long dist[maxn][maxn];
long long Pre_Dijkstra() {
  set<pair<long long, int> > S;
  for (int i = 0; i <= n; ++i) d[i] = INFL;
  d[s] = 0;
  S.clear();
  S.insert(pair<long long, int>(0, s));
  while (S.size()) {
    pair<long long, int> temp = *S.begin();
    S.erase(S.begin());
    int u = temp.second;
    for (int k = 0; k < adj[u].size(); ++k) {
      int v = adj[u][k].first;
      if (dist[u][v] == -1) continue;
      int w = abs(dist[u][v]);
      if (d[v] > d[u] + (long long)w) {
        S.erase(pair<long long, int>(d[v], v));
        d[v] = d[u] + (long long)w;
        S.insert(pair<long long, int>(d[v], v));
      }
    }
  }
  return d[t];
}
long long Dijkstra() {
  set<pair<long long, int> > S;
  S.clear();
  for (int i = 0; i <= n; ++i) d[i] = INFL;
  d[s] = 0;
  S.insert(pair<long long, int>(d[s], s));
  T[s] = 0;
  while (S.size()) {
    pair<long long, int> temp = *S.begin();
    S.erase(S.begin());
    int u = temp.second;
    for (int k = 0; k < adj[u].size(); ++k) {
      int v = adj[u][k].first;
      int w = abs(dist[u][v]);
      if (d[v] > d[u] + (long long)w) {
        S.erase(pair<long long, int>(d[v], v));
        T[v] = u;
        d[v] = d[u] + (long long)w;
        S.insert(pair<long long, int>(d[v], v));
      }
    }
  }
  int v = t;
  while (T[v] != 0) {
    if (dist[T[v]][v] < 0) {
      dist[T[v]][v] = -2;
      dist[v][T[v]] = -2;
    }
    v = T[v];
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (dist[i][j] == -1) dist[i][j] = INFL;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (dist[i][j] == -2) dist[i][j] = -1;
  return d[t];
}
int Pow[10];
int Count(int v) {
  int d = 0;
  while (v) d++, v /= 10;
  return d;
}
bool Relax() {
  set<pair<long long, int> > S;
  S.clear();
  for (int i = 1; i <= n; ++i) d[i] = INFL;
  d[s] = 0;
  T[s] = 0;
  S.insert(pair<long long, int>(0, s));
  while (S.size()) {
    pair<long long, int> temp = *S.begin();
    S.erase(S.begin());
    int u = temp.second;
    for (int k = 0; k < adj[u].size(); ++k) {
      int v = adj[u][k].first;
      long long w = abs(dist[u][v]);
      if (d[v] > d[u] + w) {
        S.erase(pair<long long, int>(d[v], v));
        d[v] = d[u] + w;
        T[v] = u;
        S.insert(pair<long long, int>(d[v], v));
      }
    }
  }
  if (d[t] == L) return 1;
  int v = t;
  bool meet = 0;
  while (T[v] != 0) {
    int u = T[v];
    if (!meet && dist[u][v] < 0) {
      dist[u][v] = abs(dist[u][v]) + L - d[t];
      dist[v][u] = abs(dist[v][u]) + L - d[t];
      meet = 1;
    }
    if (meet) break;
    v = T[v];
  }
  return 0;
}
int main() {
  Read(n);
  Read(m);
  Read(L);
  Read(s);
  Read(t);
  s++;
  t++;
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    Read(u);
    Read(v);
    Read(w);
    u++;
    v++;
    E[i] = Edge(u, v, w);
    dist[u][v] = w;
    dist[v][u] = w;
    if (w == 0) {
      dist[u][v] = -1;
      dist[v][u] = -1;
    }
    adj[u].push_back(pair<int, int>(v, w));
    adj[v].push_back(pair<int, int>(u, w));
  }
  long long SPath1 = Pre_Dijkstra();
  if (SPath1 < L) {
    puts("NO");
    return 0;
  }
  if (SPath1 == L) {
    puts("YES");
    for (int i = 1; i <= m; ++i) {
      Write(E[i].u - 1);
      putchar(' ');
      Write(E[i].v - 1);
      putchar(' ');
      if (E[i].w == 0)
        Write(INFL);
      else
        Write(E[i].w);
      putchar('\n');
    }
    return 0;
  }
  long long SPath2 = Dijkstra();
  if (SPath2 > L) {
    puts("NO");
    return 0;
  }
  puts("YES");
  bool k = Relax();
  while (!k) k = Relax();
  for (int i = 1; i <= m; ++i) {
    Write(E[i].u - 1);
    putchar(' ');
    Write(E[i].v - 1);
    putchar(' ');
    Write(abs(dist[E[i].u][E[i].v]));
    putchar('\n');
  }
  return 0;
}
