/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<bits/stdc++.h>

//#include<algorithm>
//#include<cstdio>
//#include<sstream>
//#include<cstdlib>
//#include<cctype>
//#include<cmath>
//#include<set>
//#include<queue>
//#include<stack>
//#include<list>
//#include<iostream>
//#include<fstream>
//#include<numeric>
//#include<string>
//#include<vector>
//#include<cstring>
//#include<map>
//#include<iterator>
//#include<deque>
//#include<climits>
//#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair
#define NL P("\n")

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

// I/O
#define I(X)                       scanf("%d", &(X))
#define II(X, Y)                   scanf("%d%d", &(X), &(Y))
#define III(X, Y, Z)               scanf("%d%d%d", &(X), &(Y), &(Z))
#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define ILL(X)          scanf("%lld", &(X))
#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)
#define CMPL       cerr<< "Compilation Process Finished\n";cerr<< "----------------------------\n"

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

/// Hashing Bases & MOD
///           0123456789
#define Base1 10000019ULL
#define Base2 10000079ULL
#define Base3 10000103ULL
#define MOD1  1000000007ULL
#define MOD2  1000000009ULL
#define MOD3  1000000021ULL
#define LOGX  17
#define FCIN  ios_base::sync_with_stdio(0); cin.tie(0)

LL dis[1007];
bool vis[1007];
bool erase[10007];
VI adj[MX];
int val[MX];
pair< PII , int > edge[10007];

void Init(int n){
    for (int i=0;i<=n;i++){
        dis[i] = 1LL<<60;
        vis[i] = 0;
    }
}

void SPFA(int s,int n){
    queue<int> q;
    Init(n);

    q.PS(s);
    dis[s] = 0;
    vis[s] = 1;

    while(!q.empty()){
        int u = q.front();q.pop();

        vis[s] = 0;

        for (int i=0;i<adj[u].size();i+=2){
            int v = adj[u][i];
            int id = adj[u][i+1];
            int w = edge[id].Y;

            dis[v] = min(dis[v], dis[u]+w);

            if (!vis[v]){
                q.PS(v);
                vis[v] = 1;
            }
        }
    }
}

int main(){
    //cout << sizeof(dis)/1e6 << endl;
    //cout << sizeof(par)/1e6 << endl;
    //cout << sizeof(del)/1e6 << endl;
    //cout << sizeof(vis)/1e6 << endl;

    DII(n,m);
    DIII(l,s,t);

    for (int i=1;i<=m;i++){
        DIII(u,v,w);

        if (!w)
            erase[i] = 1, w = 1;

        adj[u].PB(v);
        adj[u].PB(i);

        adj[v].PB(u);
        adj[v].PB(i);

        edge[i] = MP( MP(u,v),w );
    }

    SPFA(s,n);

    if (dis[t] > l){
        puts("NO");
        return 0;
    }

    for (int i=1;i<=m;i++){
        if (!erase[i])  continue;

        SPFA(s,n);

        if (dis[t] <= l)
            edge[id].Y += (l-dis[t]);
    }

    SPFA(s,n);

    if (dis[t] != l){
        puts("NO");
        return 0;
    }

    puts("YES");

    for (int i=1;i<=m;i++)
        P("%d %d %d\n",edge[i].X.X, edge[i].X.Y, edge[i].Y);

return 0;
}
/*
5 2 13 0 4
0 1 5
2 1 0
*
4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
*/


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<bits/stdc++.h>

//#include<algorithm>
//#include<cstdio>
//#include<sstream>
//#include<cstdlib>
//#include<cctype>
//#include<cmath>
//#include<set>
//#include<queue>
//#include<stack>
//#include<list>
//#include<iostream>
//#include<fstream>
//#include<numeric>
//#include<string>
//#include<vector>
//#include<cstring>
//#include<map>
//#include<iterator>
//#include<deque>
//#include<climits>
//#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair
#define NL P("\n")

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

// I/O
#define I(X)                       scanf("%d", &(X))
#define II(X, Y)                   scanf("%d%d", &(X), &(Y))
#define III(X, Y, Z)               scanf("%d%d%d", &(X), &(Y), &(Z))
#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define ILL(X)          scanf("%lld", &(X))
#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)
#define CMPL       cerr<< "Compilation Process Finished\n";cerr<< "----------------------------\n"

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

/// Hashing Bases & MOD
///           0123456789
#define Base1 10000019ULL
#define Base2 10000079ULL
#define Base3 10000103ULL
#define MOD1  1000000007ULL
#define MOD2  1000000009ULL
#define MOD3  1000000021ULL
#define LOGX  17
#define FCIN  ios_base::sync_with_stdio(0); cin.tie(0)

LL dis[1007][10007];
short par[1007][10007];
short del[1007][10007];
bool vis[1007][10007];
VI adj[MX];
pair< PII , int > edge[10007];

void SPFA(int s){
    queue<int>q;

    q.PS(s);
    q.PS(0);

    vis[s][0] = 1;
    par[s][0] = -1;
    dis[s][0] = 0;

    while(!q.empty()){
        int u = q.front();q.pop();
        int x = q.front();q.pop();

        vis[u][x] = 0;

        for (int i=0;i<adj[u].size();i+=3){
            int v = adj[u][i];
            int w = adj[u][i+1];
            int id = adj[u][i+2];

            if (dis[v][x+(w==0)] > dis[u][x]+w){
                dis[v][x+(w==0)] = dis[u][x]+w;
                par[v][x+(w==0)] = u;
                del[v][x+(w==0)] = id;

                if (!vis[v][x+(w==0)]){
                    q.PS(v);
                    q.PS(x+(w==0));
                    vis[v][x+(w==0)] = 1;
                }
            }
        }
    }
}

void Init(int n,int m){
    for (int i=0;i<=n;i++){
        for (int j=0;j<=m;j++){
            dis[i][j] = 1LL<<60;
        }
    }
}

int main(){
    //cout << sizeof(dis)/1e6 << endl;
    //cout << sizeof(par)/1e6 << endl;
    //cout << sizeof(del)/1e6 << endl;
    //cout << sizeof(vis)/1e6 << endl;

    DII(n,m);
    DIII(l,s,t);

    Init(n,m);

    for (int i=1;i<=m;i++){
        DIII(u,v,w);

        adj[u].PB(v);
        adj[u].PB(w);
        adj[u].PB(i);

        adj[v].PB(u);
        adj[v].PB(w);
        adj[v].PB(i);

        edge[i] = MP( MP(u,v),w );
    }

    SPFA(s);

    if (dis[t][0] == l){
        LL lim = 1000000000000000000LL;

        puts("YES");
        for (int i=1;i<=n;i++){
            P("%d %d ",edge[i].X.X,edge[i].X.Y);

            if (edge[i].Y == 0) P("%lld\n",lim);
            else                P("%d\n",edge[i].Y);
        }

        return 0;
    }

    for (int i=1;i<=m;i++){
        //cout << dis[t][i] << endl;
        if (l - dis[t][i] < i)  continue;

        VI xx;

        int u = t, x = i;
        //cout << "Path:\n";
        while(par[u][x] != -1){
            //cout << u << ": " << x << endl;
            int id = del[u][x];
            //cout << id << endl;
            if (edge[id].Y == 0){
                //cout << "Dhuklo\n";
                xx.PB(id);
            }

            u = par[u][x];
            if (edge[id].Y == 0)
                x --;
        }
        //cout << "--------\n";

        int baki = l - dis[t][i];

        for (int j=0;j<xx.size();j++){
            //cout << "-> " << xx[j] << endl;
            edge[ xx[j] ].Y = 1;
            baki --;
        }

        edge[ xx.back() ].Y += baki;

        puts("YES");
        for (int j=1;j<=m;j++){
            P("%d %d %d\n",edge[j].X.X, edge[j].X.Y, edge[j].Y);
        }

        return 0;
    }

    puts("NO");
return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<bits/stdc++.h>

//#include<algorithm>
//#include<cstdio>
//#include<sstream>
//#include<cstdlib>
//#include<cctype>
//#include<cmath>
//#include<set>
//#include<queue>
//#include<stack>
//#include<list>
//#include<iostream>
//#include<fstream>
//#include<numeric>
//#include<string>
//#include<vector>
//#include<cstring>
//#include<map>
//#include<iterator>
//#include<deque>
//#include<climits>
//#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair
#define NL P("\n")

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

// I/O
#define I(X)                       scanf("%d", &(X))
#define II(X, Y)                   scanf("%d%d", &(X), &(Y))
#define III(X, Y, Z)               scanf("%d%d%d", &(X), &(Y), &(Z))
#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define ILL(X)          scanf("%lld", &(X))
#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)
#define CMPL       cerr<< "Compilation Process Finished\n";cerr<< "----------------------------\n"

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

/// Hashing Bases & MOD
///           0123456789
#define Base1 10000019ULL
#define Base2 10000079ULL
#define Base3 10000103ULL
#define MOD1  1000000007ULL
#define MOD2  1000000009ULL
#define MOD3  1000000021ULL
#define LOGX  17
#define FCIN  ios_base::sync_with_stdio(0); cin.tie(0)

LL dis[1007];
bool vis[1007];
bool erase[10007];
VI adj[MX];
int val[MX];
pair< PII , int > edge[10007];

void Init(int n){
    for (int i=0;i<=n;i++){
        dis[i] = 1LL<<60;
        vis[i] = 0;
    }
}

void SPFA(int s,int n){
    queue<int> q;
    Init(n);

    q.PS(s);
    dis[s] = 0;
    vis[s] = 1;

    while(!q.empty()){
        int u = q.front();q.pop();

        vis[u] = 0;

        for (int i=0;i<adj[u].size();i+=2){
            int v = adj[u][i];
            int id = adj[u][i+1];
            int w = edge[id].Y;

            if (dis[v] <= dis[u]+w) continue;

            dis[v] = min(dis[v], dis[u]+w);

            if (!vis[v]){
                q.PS(v);
                vis[v] = 1;
            }
        }
    }
}

int main(){
    //cout << sizeof(dis)/1e6 << endl;
    //cout << sizeof(par)/1e6 << endl;
    //cout << sizeof(del)/1e6 << endl;
    //cout << sizeof(vis)/1e6 << endl;

    DII(n,m);
    DIII(l,s,t);

    for (int i=1;i<=m;i++){
        DIII(u,v,w);

        if (!w)
            erase[i] = 1;

        adj[u].PB(v);
        adj[u].PB(i);

        adj[v].PB(u);
        adj[v].PB(i);

        edge[i] = MP( MP(u,v),w );
    }

    for (int i=1;i<=m;i++){
        if (erase[i])
            edge[i].Y = 1;
    }

    SPFA(s,n);
    LL best = dis[t];

    for (int i=1;i<=m;i++)
        if (erase[i])
            edge[i].Y = 2e9;

    SPFA(s,n);
    LL worst = dis[t];

    if (l < best || worst < l){
        puts("NO");
        return 0;
    }

    if (worst > l)
        for (int i=1;i<=m;i++){
            if (!erase[i])  continue;

            edge[i].Y = 1;
            SPFA(s,n);

            if (dis[t] <= l){
                edge[i].Y += (l-dis[t]);
                break;
            }
        }

    SPFA(s,n);

    if (dis[t] != l){
        puts("NO");
        return 0;
    }

    puts("YES");

    for (int i=1;i<=m;i++)
        P("%d %d %d\n",edge[i].X.X, edge[i].X.Y, edge[i].Y);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<bits/stdc++.h>

//#include<algorithm>
//#include<cstdio>
//#include<sstream>
//#include<cstdlib>
//#include<cctype>
//#include<cmath>
//#include<set>
//#include<queue>
//#include<stack>
//#include<list>
//#include<iostream>
//#include<fstream>
//#include<numeric>
//#include<string>
//#include<vector>
//#include<cstring>
//#include<map>
//#include<iterator>
//#include<deque>
//#include<climits>
//#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair
#define NL P("\n")

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

// I/O
#define I(X)                       scanf("%d", &(X))
#define II(X, Y)                   scanf("%d%d", &(X), &(Y))
#define III(X, Y, Z)               scanf("%d%d%d", &(X), &(Y), &(Z))
#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define ILL(X)          scanf("%lld", &(X))
#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)
#define CMPL       cerr<< "Compilation Process Finished\n";cerr<< "----------------------------\n"

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

/// Hashing Bases & MOD
///           0123456789
#define Base1 10000019ULL
#define Base2 10000079ULL
#define Base3 10000103ULL
#define MOD1  1000000007ULL
#define MOD2  1000000009ULL
#define MOD3  1000000021ULL
#define LOGX  17
#define FCIN  ios_base::sync_with_stdio(0); cin.tie(0)

LL dis[1007];
bool vis[1007];
bool erase[10007];
VI adj[MX];
int val[MX];
pair< PII , int > edge[10007];

void Init(int n){
    for (int i=0;i<=n;i++){
        dis[i] = 1LL<<60;
        vis[i] = 0;
    }
}

void SPFA(int s,int n){
    queue<int> q;
    Init(n);

    q.PS(s);
    dis[s] = 0;
    vis[s] = 1;

    while(!q.empty()){
        int u = q.front();q.pop();

        vis[u] = 0;

        for (int i=0;i<adj[u].size();i+=2){
            int v = adj[u][i];
            int id = adj[u][i+1];
            int w = edge[id].Y;

            dis[v] = min(dis[v], dis[u]+w);

            if (!vis[v]){
                q.PS(v);
                vis[v] = 1;
            }
        }
    }
}

int main(){
    //cout << sizeof(dis)/1e6 << endl;
    //cout << sizeof(par)/1e6 << endl;
    //cout << sizeof(del)/1e6 << endl;
    //cout << sizeof(vis)/1e6 << endl;

    DII(n,m);
    DIII(l,s,t);

    for (int i=1;i<=m;i++){
        DIII(u,v,w);

        if (!w)
            erase[i] = 1;

        adj[u].PB(v);
        adj[u].PB(i);

        adj[v].PB(u);
        adj[v].PB(i);

        edge[i] = MP( MP(u,v),w );
    }

    for (int i=1;i<=m;i++){
        if (erase[i])
            edge[i].Y = 1;
    }

    SPFA(s,n);
    LL best = dis[t];

    for (int i=1;i<=m;i++)
        if (erase[i])
            edge[i].Y = 2e9;

    SPFA(s,n);
    LL worst = dis[t];

    if (l < best || worst < l){
        puts("NO");
        return 0;
    }

    if (worst > l)
        for (int i=1;i<=m;i++){
            if (!erase[i])  continue;

            edge[i].Y = 1;
            SPFA(s,n);

            if (dis[t] <= l){
                edge[i].Y += (l-dis[t]);
                break;
            }
        }

    SPFA(s,n);

    if (dis[t] != l){
        puts("NO");
        return 0;
    }

    puts("YES");

    for (int i=1;i<=m;i++)
        P("%d %d %d\n",edge[i].X.X, edge[i].X.Y, edge[i].Y);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<bits/stdc++.h>

//#include<algorithm>
//#include<cstdio>
//#include<sstream>
//#include<cstdlib>
//#include<cctype>
//#include<cmath>
//#include<set>
//#include<queue>
//#include<stack>
//#include<list>
//#include<iostream>
//#include<fstream>
//#include<numeric>
//#include<string>
//#include<vector>
//#include<cstring>
//#include<map>
//#include<iterator>
//#include<deque>
//#include<climits>
//#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair
#define NL P("\n")

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

// I/O
#define I(X)                       scanf("%d", &(X))
#define II(X, Y)                   scanf("%d%d", &(X), &(Y))
#define III(X, Y, Z)               scanf("%d%d%d", &(X), &(Y), &(Z))
#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define ILL(X)          scanf("%lld", &(X))
#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)
#define CMPL       cerr<< "Compilation Process Finished\n";cerr<< "----------------------------\n"

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

/// Hashing Bases & MOD
///           0123456789
#define Base1 10000019ULL
#define Base2 10000079ULL
#define Base3 10000103ULL
#define MOD1  1000000007ULL
#define MOD2  1000000009ULL
#define MOD3  1000000021ULL
#define LOGX  17
#define FCIN  ios_base::sync_with_stdio(0); cin.tie(0)

LL dis[1007];
bool vis[1007];
bool erase[10007];
VI adj[MX];
int val[MX];
pair< PII , int > edge[10007];

void Init(int n){
    for (int i=0;i<=n;i++){
        dis[i] = 1LL<<60;
        vis[i] = 0;
    }
}

void SPFA(int s,int n){
    queue<int> q;
    Init(n);

    q.PS(s);
    dis[s] = 0;
    vis[s] = 1;

    while(!q.empty()){
        int u = q.front();q.pop();

        vis[s] = 0;

        for (int i=0;i<adj[u].size();i+=2){
            int v = adj[u][i];
            int id = adj[u][i+1];
            int w = edge[id].Y;

            dis[v] = min(dis[v], dis[u]+w);

            if (!vis[v]){
                q.PS(v);
                vis[v] = 1;
            }
        }
    }
}

int main(){
    //cout << sizeof(dis)/1e6 << endl;
    //cout << sizeof(par)/1e6 << endl;
    //cout << sizeof(del)/1e6 << endl;
    //cout << sizeof(vis)/1e6 << endl;

    DII(n,m);
    DIII(l,s,t);

    for (int i=1;i<=m;i++){
        DIII(u,v,w);

        if (!w)
            erase[i] = 1;

        adj[u].PB(v);
        adj[u].PB(i);

        adj[v].PB(u);
        adj[v].PB(i);

        edge[i] = MP( MP(u,v),w );
    }

    for (int i=1;i<=m;i++){
        if (erase[i])
            edge[i].Y = 1;
    }

    SPFA(s,n);
    LL best = dis[t];

    for (int i=1;i<=m;i++)
        if (erase[i])
            edge[i].Y = 2e9;

    SPFA(s,n);
    LL worst = dis[t];

    if (l < best || worst < l){
        puts("NO");
        return 0;
    }

    for (int i=1;i<=m;i++){
        if (!erase[i])  continue;

        edge[i].Y = 1;
        SPFA(s,n);

        if (dis[t] <= l){
            edge[i].Y += (l-dis[t]);
            break;
        }
    }

    SPFA(s,n);

    if (dis[t] != l){
        puts("NO");
        return 0;
    }

    puts("YES");

    for (int i=1;i<=m;i++)
        P("%d %d %d\n",edge[i].X.X, edge[i].X.Y, edge[i].Y);

return 0;
}


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<bits/stdc++.h>

//#include<algorithm>
//#include<cstdio>
//#include<sstream>
//#include<cstdlib>
//#include<cctype>
//#include<cmath>
//#include<set>
//#include<queue>
//#include<stack>
//#include<list>
//#include<iostream>
//#include<fstream>
//#include<numeric>
//#include<string>
//#include<vector>
//#include<cstring>
//#include<map>
//#include<iterator>
//#include<deque>
//#include<climits>
//#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair
#define NL P("\n")

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

// I/O
#define I(X)                       scanf("%d", &(X))
#define II(X, Y)                   scanf("%d%d", &(X), &(Y))
#define III(X, Y, Z)               scanf("%d%d%d", &(X), &(Y), &(Z))
#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define ILL(X)          scanf("%lld", &(X))
#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)
#define CMPL       cerr<< "Compilation Process Finished\n";cerr<< "----------------------------\n"

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

/// Hashing Bases & MOD
///           0123456789
#define Base1 10000019ULL
#define Base2 10000079ULL
#define Base3 10000103ULL
#define MOD1  1000000007ULL
#define MOD2  1000000009ULL
#define MOD3  1000000021ULL
#define LOGX  17
#define FCIN  ios_base::sync_with_stdio(0); cin.tie(0)

LL dis[1007];
bool vis[1007];
bool erase[10007];
VI adj[MX];
int val[MX];
pair< PII , int > edge[10007];

void Init(int n){
    for (int i=0;i<=n;i++){
        dis[i] = 1LL<<60;
        vis[i] = 0;
    }
}

void SPFA(int s,int n){
    queue<int> q;
    Init(n);

    q.PS(s);
    dis[s] = 0;
    vis[s] = 1;

    while(!q.empty()){
        int u = q.front();q.pop();

        vis[s] = 0;

        for (int i=0;i<adj[u].size();i+=2){
            int v = adj[u][i];
            int id = adj[u][i+1];
            int w = edge[id].Y;

            dis[v] = min(dis[v], dis[u]+w);

            if (!vis[v]){
                q.PS(v);
                vis[v] = 1;
            }
        }
    }
}

int main(){
    //cout << sizeof(dis)/1e6 << endl;
    //cout << sizeof(par)/1e6 << endl;
    //cout << sizeof(del)/1e6 << endl;
    //cout << sizeof(vis)/1e6 << endl;

    DII(n,m);
    DIII(l,s,t);

    for (int i=1;i<=m;i++){
        DIII(u,v,w);

        if (!w)
            erase[i] = 1, w = 1;

        adj[u].PB(v);
        adj[u].PB(i);

        adj[v].PB(u);
        adj[v].PB(i);

        edge[i] = MP( MP(u,v),w );
    }

    SPFA(s,n);

    if (dis[t] > l){
        puts("NO");
        return 0;
    }

    for (int i=1;i<=m;i++){
        if (!erase[i])  continue;

        SPFA(s,n);

        if (dis[t] <= l)
            edge[i].Y += (l-dis[t]);
    }

    SPFA(s,n);

    if (dis[t] != l){
        puts("NO");
        return 0;
    }

    puts("YES");

    for (int i=1;i<=m;i++)
        P("%d %d %d\n",edge[i].X.X, edge[i].X.Y, edge[i].Y);

return 0;
}
/*
5 2 13 0 4
0 1 5
2 1 0
*
4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
*/


/*****************************************************************
 *                   BISMILLAHIR RAHMANIR RAHIM                  *
 *          Raihat Zaman Neloy                                   *
 *          JU-CSE-21                                            *
 *          raihatneloy                                          *
 *****************************************************************/

#include<bits/stdc++.h>

//#include<algorithm>
//#include<cstdio>
//#include<sstream>
//#include<cstdlib>
//#include<cctype>
//#include<cmath>
//#include<set>
//#include<queue>
//#include<stack>
//#include<list>
//#include<iostream>
//#include<fstream>
//#include<numeric>
//#include<string>
//#include<vector>
//#include<cstring>
//#include<map>
//#include<iterator>
//#include<deque>
//#include<climits>
//#include<complex>

#define S scanf
#define P printf

#define LL long long int
#define ULL unsigned long long int
#define D double

#define SQR(n)      (n*n)
#define PI          2.0*acos(0.0)

#define all(a) a.begin(),a.end()
#define X  first
#define Y  second
#define MP make_pair
#define NL P("\n")

#define open       freopen("input.txt","r",stdin)
#define close      freopen ("output.txt","w",stdout)
#define S1(a)      scanf("%d",&a)
#define S2(a,b)    scanf("%d%d",&a,&b)
#define S3(a,b,c)  scanf("%d%d%d",&a,&b,&c)
#define SL1(a)     scanf("%lld",&a)
#define SL2(a,b)   scanf("%lld%lld",&a,&b)
#define SL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define CHR        getchar()
#define PB(x)      push_back(x)
#define pb         push_back
#define PP         pop_back()
#define PF(x)      push_front(x)
#define PPF(x)     pop_front()
#define PS(x)      push(x)
#define sz()       size()
#define UB         upper_bound
#define LB         lower_bound
#define mxe(a,n)   (*max_element(a,a+n))
#define mne(a,n)   (*min_element(a,a+n))
#define SUM(a,n)   (accumulate(a,a+n,0))
#define countbit(x) __builtin_popcount(x)
#define DBG(n)      P("Done %d\n",n);

// I/O
#define I(X)                       scanf("%d", &(X))
#define II(X, Y)                   scanf("%d%d", &(X), &(Y))
#define III(X, Y, Z)               scanf("%d%d%d", &(X), &(Y), &(Z))
#define DI(X) int (X);             scanf("%d", &X)
#define DII(X, Y) int X, Y;        scanf("%d%d", &X, &Y)
#define DIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)

#define ILL(X)          scanf("%lld", &(X))
#define DILL(X) LL (X); scanf("%lld", &X)

// LOOP
#define repv(i,a) for(int i=0;i<(int)a.size();i++)
#define revv(i,a) for(int i=((int)a.size())-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

#define FS(x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)

#define MEM(a,val) memset(a,val,sizeof(a));
#define SET(a)     memset(a,-1,sizeof a)
#define CLR(a)     memset(a,0,sizeof a)
#define CMPL       cerr<< "Compilation Process Finished\n";cerr<< "----------------------------\n"

using namespace std;

template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T in(){char ch;T n = 0;bool ng = false;while (1){ch = getchar();if (ch == '-'){ng = true;ch = getchar();break;}if (ch>='0' && ch<='9')     break;}while (1){n = n*10 + (ch - '0');ch = getchar();if (ch<'0' || ch>'9')   break;}return (ng?-n:n);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
template <typename T> T Bigmod(T b,T p,T m){ if(p==0) return 1; else if (!(p&1)) return SQR(Bigmod(b,p/2,m)) % m;else return ((b % m) * Bigmod(b,p-1,m)) % m;}
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan( double(y1-y2) / double(x1-x2));}
template <typename T> T DIFF(T a,T b) { T d = a-b;if(d<0)return -d;else return d;}
template <typename T> T ABS(T a) {if(a<0)return -a;else return a;}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
template <typename T> T euclide(T a,T b,T &x,T &y) {if(a<0){T d=euclide(-a,b,x,y);x=-x;return d;}   if(b<0){T d=euclide(a,-b,x,y);y=-y;return d;}   if(b==0){x=1;y=0;return a;}else{T d=euclide(b,a%b,x,y);T t=x;x=y;y=t-(a/b)*y;return d;}}
template <typename T> void ia (T a[],int n){for (int i=0; i<n; i++) cin >> a[i];}
template <typename T> void pa (T a[],int n){for (int i=0; i<n-1; i++) cout << a[i] << " ";cout << a[n-1] << endl;}
template <typename T> LL isLeft(T a,T b,T c) { return (a.x-b.x)*(b.y-c.y)-(b.x-c.x)*(a.y-b.y); }

int    Set(int N,int pos){ return N=N | (1<<pos);}
int  Reset(int N,int pos){return N= N & ~(1<<pos);}
bool Check(int N,int pos){return (bool)(N & (1<<pos));}
template< class T, class X > inline T   togglebit(T a, X i) { T t=1;return (a^(t<<i)); }

double DEG(double x) { return (180.0*x)/(PI);}
double RAD(double x) { return (x*(double)PI)/(180.0);}

#define VI  vector< int >
#define VII vector< VI >
#define VLL vector< LL >
#define PII pair< int , int >
#define PLL pair< LL , LL >
#define VPI vector< PII >

///         0123456789
#define MX  100007
#define MOD 1000000007
#define INF (1<<30)-1+(1<<30)
#define eps 1e-9

#define base ((1<<l)-1)
#define lft (idx<<1)
#define rgt (lft|1)
#define mid ((l+r)>>1)

/// Hashing Bases & MOD
///           0123456789
#define Base1 10000019ULL
#define Base2 10000079ULL
#define Base3 10000103ULL
#define MOD1  1000000007ULL
#define MOD2  1000000009ULL
#define MOD3  1000000021ULL
#define LOGX  17
#define FCIN  ios_base::sync_with_stdio(0); cin.tie(0)

LL dis[1007];
bool vis[1007];
bool erase[10007];
VI adj[MX];
int val[MX];
pair< PII , int > edge[10007];

void Init(int n){
    for (int i=0;i<=n;i++){
        dis[i] = 1LL<<60;
        vis[i] = 0;
    }
}

void SPFA(int s,int n){
    queue<int> q;
    Init(n);

    q.PS(s);
    dis[s] = 0;
    vis[s] = 1;

    while(!q.empty()){
        int u = q.front();q.pop();

        vis[s] = 0;

        for (int i=0;i<adj[u].size();i+=2){
            int v = adj[u][i];
            int id = adj[u][i+1];
            int w = edge[id].Y;

            dis[v] = min(dis[v], dis[u]+w);

            if (!vis[v]){
                q.PS(v);
                vis[v] = 1;
            }
        }
    }
}

int main(){
    //cout << sizeof(dis)/1e6 << endl;
    //cout << sizeof(par)/1e6 << endl;
    //cout << sizeof(del)/1e6 << endl;
    //cout << sizeof(vis)/1e6 << endl;

    DII(n,m);
    DIII(l,s,t);

    for (int i=1;i<=m;i++){
        DIII(u,v,w);

        if (!w)
            erase[i] = 1, w = 1;

        adj[u].PB(v);
        adj[u].PB(i);

        adj[v].PB(u);
        adj[v].PB(i);

        edge[i] = MP( MP(u,v),w );
    }

    SPFA(s,n);

    if (dis[t] > l){
        puts("NO");
        return 0;
    }

    for (int u=0;u<n;u++){
        for (int i=0;i<adj[u].size();i+=2){
            int id = adj[u][i+1];
            //cout << id << "-> " << erase[id] << endl;
            if (!erase[id]) continue;

            SPFA(s,n);
            //cout << id << ": " << dis[t] << endl;
            if (dis[t] <= l)
                edge[id].Y += (l-dis[t]);
        }
    }

    SPFA(s,n);

    if (dis[t] != l){
        puts("NO");
        return 0;
    }

    for (int i=1;i<=m;i++)
        P("%d %d %d\n",edge[i].X.X, edge[i].X.Y, edge[i].Y);

return 0;
}
/*
5 2 13 0 4
0 1 5
2 1 0
*
4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
*/


#include <bits/stdc++.h>
#include <tr1/unordered_map>
typedef long long ll;
typedef unsigned long long ull;
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf 10000001
#define vi vector<int>
#define pi pair<int  ,ll >
#define T pair<pi  ,int >
#define mk make_pair
#define getBit(m,i) ((m&(1<<i))==(1<<i))
#define setBit(m,i) (m|(1<<i))
#define setBit2(m,i) (m|(1ull<<i))
#define cont(i,ma) ((ma.find(i))!=(ma.end()))
#define in(i) scanf("%d",&i)
#define in2(i,j) scanf("%d%d",&i,&j)
#define in3(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define in4(i,j,k,l) scanf("%d%d%d%d",&i,&j,&k,&l)
#define il(i) scanf("%I64d",&i)
#define itr map<ll,ll>::iterator
#define itr2 map<ll,map<ll,ll> >::iterator
#define id(k) scanf("%9lf",&k)
#define fi(ss) freopen (ss,"r",stdin)
#define fo(ss) freopen (ss,"w",stdout)
#define clean(vis)  memset(vis,0,sizeof vis)
using namespace std;
vi g [1000+5];
int cost [1000+5][1000+5];
bool done [1000+5][1000+5];
int par[1000+5];
bool vis [1000+5];
vector<pi> res;
int n,m,l,s,t;
struct com{
    bool operator ()(T a,T b){
        return a.first.second>b.first.second;
    }
};
ll dik(){
    clean(vis);
    clr(par);
    priority_queue<T,vector<T>,com> q;
    q.push(mk(mk(s,0),-1));
    int x, y;ll d;
    while (!q.empty()){
        T p=q.top();
        q.pop();
        x=p.first.first;d=p.first.second;y=p.second;
        if (vis[x])continue;
        vis[x]=1;
        par[x]=y;
        if (x==t)return d;
        for (int i=0;i<g[x].size();i++){
            y=g[x][i];
            q.push(mk(mk(y,d+(cost[x][y]==0?l+1:cost[x][y])),x));
        }

    }
    return l-1;
}
int main(){
   in4(n,m,l,s);
    in(t);
    int x,y,c;
    clr(cost);
    bool f=0;
    for (int i=0;i<m;i++){
        in3(x,y,c);
        g[x].push_back(y);
        g[y].push_back(x);
        cost[x][y]=c;
        cost[y][x]=c;
        res.push_back(mk(x,y));
        if (c==0)f=1;
        if (c!=0)done[x][y]=done[y][x]=1;
    }
    ll ans=dik();
    if (ans<l || (l<ans && !f)){
        cout<<"NO\n";
        return 0;
    }
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)if (!cost[i][j])cost[i][j]=1;
    if (ans!=l){
       while (1){
           ll ans=dik();
           if (ans==l)break;
           c=t;
           while (par[c]!=-1){
               int p=par[c];
               if (!done[p][c]){
                   cost[p][c]+=l-ans;
                   cost[c][p]+=l-ans;
                   done[p][c]=done[c][p]=1;
                   break;
               }
               c=p;
           }

       }
    }
    cout<<"YES\n";//
    for (int i=0;i<m;i++)cout<<res[i].first<<" "<<res[i].second<<" "<<((done[res[i].first][res[i].second]==0)?l+1:cost[res[i].first][res[i].second])<<"\n";
}


#include <bits/stdc++.h>
#include <tr1/unordered_map>
typedef long long ll;
typedef unsigned long long ull;
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf 10000000000000ll
#define vi vector<int>
#define pi pair<int  ,ll >
#define T pair<pi  ,int >
#define mk make_pair
#define getBit(m,i) ((m&(1<<i))==(1<<i))
#define setBit(m,i) (m|(1<<i))
#define setBit2(m,i) (m|(1ull<<i))
#define cont(i,ma) ((ma.find(i))!=(ma.end()))
#define in(i) scanf("%d",&i)
#define in2(i,j) scanf("%d%d",&i,&j)
#define in3(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define in4(i,j,k,l) scanf("%d%d%d%d",&i,&j,&k,&l)
#define il(i) scanf("%I64d",&i)
#define itr map<ll,ll>::iterator
#define itr2 map<ll,map<ll,ll> >::iterator
#define id(k) scanf("%9lf",&k)
#define fi(ss) freopen (ss,"r",stdin)
#define fo(ss) freopen (ss,"w",stdout)
#define clean(vis)  memset(vis,0,sizeof vis)
using namespace std;
vi g [1000+5];
int cost [1000+5][1000+5];
bool done [1000+5][1000+5];
ll dis [1000+5];
int par[1000+5];
vector<pi> res;
int n,m,l,s,t;
struct com{
    bool operator ()(T &a,T &b){
        return a.first.second>b.first.second;
    }
};
ll dik(){
    clr(par);
    for (int i=0;i<n;i++)dis[i]=inf;
    priority_queue<T,vector<T>,com> q;
    q.push(mk(mk(s,0),-1));
    int x, y;ll d;
    while (!q.empty()){
        T p=q.top();
        q.pop();
        x=p.first.first;d=p.first.second;y=p.second;
        if (dis[x]<d)continue;
        if (x==t)return d;
        for (int i=0;i<g[x].size();i++){
            y=g[x][i];
            if (dis[y]>d+(cost[x][y]==0?l+1:cost[x][y])) {
                par[y]=x;
                dis[y]=d+(cost[x][y]==0?l+1:cost[x][y]);
                q.push(mk(mk(y, d + (cost[x][y] == 0 ? l + 1 : cost[x][y])), x));
            }
        }

    }
    return l-1;
}
int main(){
   in4(n,m,l,s);
    in(t);
    int x,y,c;
    clr(cost);
    bool f=0;
    for (int i=0;i<m;i++){
        in3(x,y,c);
        g[x].push_back(y);
        g[y].push_back(x);
        cost[x][y]=c;
        cost[y][x]=c;
        res.push_back(mk(x,y));
        if (c==0)f=1;
        if (c!=0)done[x][y]=done[y][x]=1;
    }
    ll ans=dik();
    if (ans<l || (l<ans && !f)){
        cout<<"NO\n";
        return 0;
    }
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)if (!cost[i][j])cost[i][j]=1;
       while (1){
           ll ans=dik();
           if (ans>l){
               cout<<"NO\n";
               return 0;
           }
           if (ans==l)break;
           c=t;
           while (par[c]!=-1){
               int p=par[c];
               if (!done[p][c]){
                   cost[p][c]+=l-ans;
                   cost[c][p]+=l-ans;
                   done[p][c]=done[c][p]=1;
                   break;
               }
               c=p;
           }

       }
    cout<<"YES\n";//
    for (int i=0;i<m;i++)cout<<res[i].first<<" "<<res[i].second<<" "<<((done[res[i].first][res[i].second]==0)?1:cost[res[i].first][res[i].second])<<"\n";
}


#include <bits/stdc++.h>
#include <tr1/unordered_map>
typedef long long ll;
typedef unsigned long long ull;
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf 10000001
#define vi vector<int>
#define pi pair<int  ,ll >
#define T pair<pi  ,int >
#define mk make_pair
#define getBit(m,i) ((m&(1<<i))==(1<<i))
#define setBit(m,i) (m|(1<<i))
#define setBit2(m,i) (m|(1ull<<i))
#define cont(i,ma) ((ma.find(i))!=(ma.end()))
#define in(i) scanf("%d",&i)
#define in2(i,j) scanf("%d%d",&i,&j)
#define in3(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define in4(i,j,k,l) scanf("%d%d%d%d",&i,&j,&k,&l)
#define il(i) scanf("%I64d",&i)
#define itr map<ll,ll>::iterator
#define itr2 map<ll,map<ll,ll> >::iterator
#define id(k) scanf("%9lf",&k)
#define fi(ss) freopen (ss,"r",stdin)
#define fo(ss) freopen (ss,"w",stdout)
#define clean(vis)  memset(vis,0,sizeof vis)
using namespace std;
vi g [1000+5];
int cost [1000+5][1000+5];
bool done [1000+5][1000+5];
int par[1000+5];
bool vis [1000+5];
vector<pi> res;
int n,m,l,s,t;
struct com{
    bool operator ()(T a,T b){
        return a.first.second>b.first.second;
    }
};
ll dik(){
    clean(vis);
    clr(par);
    priority_queue<T,vector<T>,com> q;
    q.push(mk(mk(s,0),-1));
    int x, y;ll d;
    while (!q.empty()){
        T p=q.top();
        q.pop();
        x=p.first.first;d=p.first.second;y=p.second;
        if (vis[x])continue;
        vis[x]=1;
        par[x]=y;
        if (x==t)return d;
        for (int i=0;i<g[x].size();i++){
            y=g[x][i];
            q.push(mk(mk(y,d+(cost[x][y]==0?l+1:cost[x][y])),x));
        }

    }
    return l-1;
}
int main(){
   in4(n,m,l,s);
    in(t);
    int x,y,c;
    clr(cost);
    bool f=0;
    for (int i=0;i<m;i++){
        in3(x,y,c);
        g[x].push_back(y);
        g[y].push_back(x);
        cost[x][y]=c;
        cost[y][x]=c;
        res.push_back(mk(x,y));
        if (c==0)f=1;
        if (c!=0)done[x][y]=done[y][x]=1;
    }
    ll ans=dik();
    if (ans<l || (l<ans && !f)){
        cout<<"NO\n";
        return 0;
    }
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)if (!cost[i][j])cost[i][j]=1;
       while (1){
           ll ans=dik();
           if (ans>l){
               cout<<"NO\n";
               return 0;
           }
           if (ans==l)break;
           c=t;
           while (par[c]!=-1){
               int p=par[c];
               if (!done[p][c]){
                   cost[p][c]+=l-ans;
                   cost[c][p]+=l-ans;
                   done[p][c]=done[c][p]=1;
                   break;
               }
               c=p;
           }

       }
    cout<<"YES\n";//
    for (int i=0;i<m;i++)cout<<res[i].first<<" "<<res[i].second<<" "<<((done[res[i].first][res[i].second]==0)?1:cost[res[i].first][res[i].second])<<"\n";
}


#include <bits/stdc++.h>
#include <tr1/unordered_map>
typedef long long ll;
typedef unsigned long long ull;
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf 10000001
#define vi vector<int>
#define pi pair<int  ,ll >
#define T pair<pi  ,int >
#define mk make_pair
#define getBit(m,i) ((m&(1<<i))==(1<<i))
#define setBit(m,i) (m|(1<<i))
#define setBit2(m,i) (m|(1ull<<i))
#define cont(i,ma) ((ma.find(i))!=(ma.end()))
#define in(i) scanf("%d",&i)
#define in2(i,j) scanf("%d%d",&i,&j)
#define in3(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define in4(i,j,k,l) scanf("%d%d%d%d",&i,&j,&k,&l)
#define il(i) scanf("%I64d",&i)
#define itr map<ll,ll>::iterator
#define itr2 map<ll,map<ll,ll> >::iterator
#define id(k) scanf("%9lf",&k)
#define fi(ss) freopen (ss,"r",stdin)
#define fo(ss) freopen (ss,"w",stdout)
#define clean(vis)  memset(vis,0,sizeof vis)
using namespace std;
vi g [1000+5];
int cost [1000+5][1000+5];
bool done [1000+5][1000+5];
int par[1000+5];
bool vis [1000+5];
vector<pi> res;
int n,m,l,s,t;
struct com{
    bool operator ()(T a,T b){
        return a.first.second>b.first.second;
    }
};
ll dik(){
    clean(vis);
    clr(par);
    priority_queue<T,vector<T>,com> q;
    q.push(mk(mk(s,0),-1));
    int x, y;ll d;
    while (!q.empty()){
        T p=q.top();
        q.pop();
        x=p.first.first;d=p.first.second;y=p.second;
        if (vis[x])continue;
        vis[x]=1;
        par[x]=y;
        if (x==t)return d;
        for (int i=0;i<g[x].size();i++){
            y=g[x][i];
            q.push(mk(mk(y,d+(cost[x][y]==0?l+1:cost[x][y])),x));
        }

    }
    return l-1;
}
int main(){
   in4(n,m,l,s);
    in(t);
    int x,y,c;
    clr(cost);
    bool f=0;
    for (int i=0;i<m;i++){
        in3(x,y,c);
        g[x].push_back(y);
        g[y].push_back(x);
        cost[x][y]=c;
        cost[y][x]=c;
        res.push_back(mk(x,y));
        if (c==0)f=1;
        if (c!=0)done[x][y]=done[y][x]=1;
    }
    ll ans=dik();
    if (ans<l || (l<ans && !f)){
        cout<<"NO\n";
        return 0;
    }
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)if (!cost[i][j])cost[i][j]=1;
    if (ans!=l){
       while (1){
           ll ans=dik();
           if (ans==l)break;
           c=t;
           while (par[c]!=-1){
               int p=par[c];
               if (!done[p][c]){
                   cost[p][c]+=l-ans;
                   cost[c][p]+=l-ans;
                   done[p][c]=done[c][p]=1;
                   break;
               }
               c=p;
           }

       }
    }
    cout<<"YES\n";//
    for (int i=0;i<m;i++)printf("%d %d %d\n",res[i].first,res[i].second,done[res[i].first][res[i].second]==0?l+1:cost[res[i].first][res[i].second]);
}


#include <bits/stdc++.h>
#include <tr1/unordered_map>
typedef long long ll;
typedef unsigned long long ull;
#define clr(ma) memset(ma,-1,sizeof ma)
#define inf 10000001
#define vi vector<int>
#define pi pair<int  ,ll >
#define T pair<pi  ,int >
#define mk make_pair
#define getBit(m,i) ((m&(1<<i))==(1<<i))
#define setBit(m,i) (m|(1<<i))
#define setBit2(m,i) (m|(1ull<<i))
#define cont(i,ma) ((ma.find(i))!=(ma.end()))
#define in(i) scanf("%d",&i)
#define in2(i,j) scanf("%d%d",&i,&j)
#define in3(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define in4(i,j,k,l) scanf("%d%d%d%d",&i,&j,&k,&l)
#define il(i) scanf("%I64d",&i)
#define itr map<ll,ll>::iterator
#define itr2 map<ll,map<ll,ll> >::iterator
#define id(k) scanf("%9lf",&k)
#define fi(ss) freopen (ss,"r",stdin)
#define fo(ss) freopen (ss,"w",stdout)
#define clean(vis)  memset(vis,0,sizeof vis)
using namespace std;
vi g [1000+5];
int cost [1000+5][1000+5];
bool done [1000+5][1000+5];
int par[1000+5];
bool vis [1000+5];
vector<pi> res;
int n,m,l,s,t;
struct com{
    bool operator ()(T a,T b){
        return a.first.second>b.first.second;
    }
};
ll dik(){
    clean(vis);
    clr(par);
    priority_queue<T,vector<T>,com> q;
    q.push(mk(mk(s,0),-1));
    int x, y;ll d;
    while (!q.empty()){
        T p=q.top();
        q.pop();
        x=p.first.first;d=p.first.second;y=p.second;
        if (vis[x])continue;
        vis[x]=1;
        par[x]=y;
        if (x==t)return d;
        for (int i=0;i<g[x].size();i++){
            y=g[x][i];
            q.push(mk(mk(y,d+(cost[x][y]==0?l+1:cost[x][y])),x));
        }

    }
    return l-1;
}
int main(){
   in4(n,m,l,s);
    in(t);
    int x,y,c;
    clr(cost);
    bool f=0;
    for (int i=0;i<m;i++){
        in3(x,y,c);
        g[x].push_back(y);
        g[y].push_back(x);
        cost[x][y]=c;
        cost[y][x]=c;
        res.push_back(mk(x,y));
        if (c==0)f=1;
        if (c!=0)done[x][y]=done[y][x]=1;
    }
    ll ans=dik();
    if (ans<l || (l<ans && !f)){
        cout<<"NO\n";
        return 0;
    }
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)if (!cost[i][j])cost[i][j]=1;
    if (ans!=l){
       while (1){
           ll ans=dik();
           if (ans>l){
               cout<<"NO\n";
               return 0;
           }
           if (ans==l)break;
           c=t;
           while (par[c]!=-1){
               int p=par[c];
               if (!done[p][c]){
                   cost[p][c]+=l-ans;
                   cost[c][p]+=l-ans;
                   done[p][c]=done[c][p]=1;
                   break;
               }
               c=p;
           }

       }
    }
    cout<<"YES\n";//
    for (int i=0;i<m;i++)cout<<res[i].first<<" "<<res[i].second<<" "<<((done[res[i].first][res[i].second]==0)?l+1:cost[res[i].first][res[i].second])<<"\n";
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
int n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    int par = -1;
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }

    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                if(dist + bestTS[i] <= l)
                    adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    if(bestST[t] != l)
        cout << "NO\n";
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }

    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
int n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    int par = -1;
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                adj[u][i] = adj[i][u] = max(1, l - dist - bestTS[i]);
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    if(bestST[t] != l)
        cout << "NO\n";
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }

    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++){
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0 && bestTS[i] != -1 && l - dist - bestTS[i] > 0){
                    adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                    // cout << u << ' ' << i << ' ' << l - dist - bestTS[i] << '\n' ;
                }
            else if(adj[u][i] == 0)
                adj[u][i] = adj[i][u] = 1;
            if(~adj[u][i])
                pq.push(pii(dist + adj[u][i], i));
        }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    if(bestST[t] != l){
        cout << "NO\n";
        return;
    }
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }
    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        // if(adj[u][v] != -1)
        //     cout << "BUG\n";
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0 && bestTS[i] != -1 && l - dist - bestTS[i] > 0){
                    adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                }
            else
                adj[u][i] = adj[i][u] = 1;
            pq.push(pii(dist + adj[u][i], i));
            }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    if(bestST[t] != l){
        cout << "NO\n";
        return;
    }
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }
    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        // if(adj[u][v] != -1)
        //     cout << "BUG\n";
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++){
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0 && bestTS[i] != -1 && l - dist - bestTS[i] > 0){
                    adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                    cout << u << ' ' << i << ' ' << l - dist - bestTS[i] << '\n' ;
                }
            else if(adj[u][i] == 0)
                adj[u][i] = adj[i][u] = 1;
            if(~adj[u][i])
                pq.push(pii(dist + adj[u][i], i));
        }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    if(bestST[t] != l){
        cout << "NO\n";
        return;
    }
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }
    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        // if(adj[u][v] != -1)
        //     cout << "BUG\n";
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        if(bestST[u] != -1 && bestTS[u] != -1 && bestST[u] + bestTS[u] == l){
            cout << "YES\n";
            for(int i = 0; i < m; i++){
                W[i] = adj[U[i]][V[i]];
                if(W[i] == 0)
                    W[i] = l + 1;
               cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
            }
            return;
        }
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                if(bestTS[i] != -1){
                    if(l - dist - bestTS[i] > 0){
                        adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                        if(s == 0 && t == 988){
                            cout << "A\n";
                            return;
                        }
                    }
                }
                else
                    adj[u][i] = adj[i][u] = 1;
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    // memset(bestST, -1, sizeof bestST);
    // pq.push(pii(0, s));
    // while(pq.size()){
    //     ll dist = pq.top().first, u = pq.top().second; pq.pop();
    //     if(~bestST[u])
    //         continue;
    //     bestST[u] = dist;
    //     for(int i = 0; i < n; i++)
    //         if(adj[u][i] >= 0)
    //             pq.push(pii(dist + adj[u][i], i));
    // }
    // if(bestST[t] != l){
        cout << "NO\n";
        return;
    // }
    // else{
    //     cout << "YES\n";
    //     for(int i = 0; i < m; i++){
    //         W[i] = adj[U[i]][V[i]];
    //         cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
    //     }

    // }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        // if(adj[u][v] != -1)
        //     cout << "BUG\n";
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        if(bestST[u] != -1 && bestTS[u] != -1 && bestST[u] + bestTS[u] == l){
            cout << "YES\n";
            for(int i = 0; i < m; i++){
                W[i] = adj[U[i]][V[i]];
                if(W[i] == 0)
                    W[i] = l + 1;
               cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
            }
            return;
        }
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                if(bestTS[i] != -1 && l - dist - bestTS[i] > 0){
                    adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                }
                else
                    adj[u][i] = adj[i][u] = 1;
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    // memset(bestST, -1, sizeof bestST);
    // pq.push(pii(0, s));
    // while(pq.size()){
    //     ll dist = pq.top().first, u = pq.top().second; pq.pop();
    //     if(~bestST[u])
    //         continue;
    //     bestST[u] = dist;
    //     for(int i = 0; i < n; i++)
    //         if(adj[u][i] >= 0)
    //             pq.push(pii(dist + adj[u][i], i));
    // }
    // if(bestST[t] != l){
        cout << "NO\n";
        return;
    // }
    // else{
    //     cout << "YES\n";
    //     for(int i = 0; i < m; i++){
    //         W[i] = adj[U[i]][V[i]];
    //         cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
    //     }

    // }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        // if(adj[u][v] != -1)
        //     cout << "BUG\n";
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
int n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    int par = -1;
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                if(bestTS[i] != -1)
                    adj[u][i] = adj[i][u] = max(1, l - dist - bestTS[i]);
                else
                    adj[u][i] = adj[i][u] = 1;
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    if(bestST[t] != l)
        cout << "NO\n";
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }

    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        if(bestST[u] != -1 && bestTS[u] != -1 && bestST[u] + bestTS[u] == l){
            cout << "YES\n";
            for(int i = 0; i < m; i++){
                W[i] = adj[U[i]][V[i]];
                if(W[i] == 0)
                    W[i] = l + 1;
               cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
            }
            return;
        }
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                if(bestTS[i] != -1){
                    if(l - dist - bestTS[i] > 0){
                        adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                        if(s == 0 && t == 988){
                            cout << "A\n";
                            return;
                        }
                    }
                    else
                        adj[u][i] = adj[i][u] = l + 1;
                }
                else
                    adj[u][i] = adj[i][u] = 1;
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    // memset(bestST, -1, sizeof bestST);
    // pq.push(pii(0, s));
    // while(pq.size()){
    //     ll dist = pq.top().first, u = pq.top().second; pq.pop();
    //     if(~bestST[u])
    //         continue;
    //     bestST[u] = dist;
    //     for(int i = 0; i < n; i++)
    //         if(adj[u][i] >= 0)
    //             pq.push(pii(dist + adj[u][i], i));
    // }
    // if(bestST[t] != l){
        cout << "NO\n";
        return;
    // }
    // else{
    //     cout << "YES\n";
    //     for(int i = 0; i < m; i++){
    //         W[i] = adj[U[i]][V[i]];
    //         cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
    //     }

    // }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        // if(adj[u][v] != -1)
        //     cout << "BUG\n";
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20, OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    bool found = 0;
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                if(bestTS[i] != -1){
                    if(l - dist - bestTS[i] > 0)
                        adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                    else
                        adj[u][i] = adj[i][u] = OO;
                }
                else
                    adj[u][i] = adj[i][u] = 1;
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    found = 0;
    if(bestST[t] != l){
        cout << "NO\n";
        if(found)
            cout << "-_-\n";
    }
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }

    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    bool found = 0;
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0){
                if(bestTS[i] != -1){
                    if(l - dist - bestTS[i] > 0)
                        adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                    else
                        adj[u][i] = adj[i][u] = OO;
                }
                else
                    adj[u][i] = adj[i][u] = 1;
                pq.push(pii(dist + adj[u][i], i));
            }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        int dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    found = 0;
    if(bestST[t] != l){
        cout << "NO\n";
        if(found)
            cout << "-_-\n";
    }
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }

    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
const int N = 1e3 + 20, M = 1e4 + 20;
const ll OO = 1e15;
ll n, m, l, s, t, adj[N][N], bestTS[N], bestST[N], U[M], V[M], W[M];
void solve(){
    priority_queue <pii, vector<pii>, greater<pii> >  pq;
    memset(bestST, -1, sizeof bestST), memset(bestTS, -1, sizeof bestTS);
    pq.push(pii(0, t));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestTS[u])
            continue;
        bestTS[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));

    }
    // for(int i = 0; i < n; i++)
    //     cout << bestTS[i] << ' ';
    // cout << "=========================\n";
    while(pq.size())
        pq.pop();
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++){
            if(adj[u][i] > 0)
                pq.push(pii(dist + adj[u][i], i));
            else if(adj[u][i] == 0 && bestTS[i] != -1 && l - dist - bestTS[i] > 0){
                    adj[u][i] = adj[i][u] = l - dist - bestTS[i];
                }
            else
                adj[u][i] = adj[i][u] = 1;
            pq.push(pii(dist + adj[u][i], i));
        }
    }
    memset(bestST, -1, sizeof bestST);
    pq.push(pii(0, s));
    while(pq.size()){
        ll dist = pq.top().first, u = pq.top().second; pq.pop();
        if(~bestST[u])
            continue;
        bestST[u] = dist;
        for(int i = 0; i < n; i++)
            if(adj[u][i] >= 0)
                pq.push(pii(dist + adj[u][i], i));
    }
    if(bestST[t] != l){
        cout << "NO\n";
        return;
    }
    else{
        cout << "YES\n";
        for(int i = 0; i < m; i++){
            W[i] = adj[U[i]][V[i]];
            cout << U[i] << ' ' << V[i] << ' ' << W[i] << '\n';
        }
    }
}
int main(){
    cin >> n >> m >> l >> s >> t;
    memset(adj, -1, sizeof adj);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        U[i] = u, V[i] = v, W[i] = w;
        // if(adj[u][v] != -1)
        //     cout << "BUG\n";
        adj[u][v] = adj[v][u] = w;
    }
    solve();
    return 0;
}