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;
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;
}
