7 9 999999999 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 7 9 320 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 4 5 7 0 3
0 1 0
1 2 3
2 3 0
0 2 5
1 3 5
 8 9 10 1 0
1 2 1
2 4 1
1 3 0
3 4 0
4 5 0
5 6 1
6 0 1
5 7 0
7 0 0
 4 4 14 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 5 6 1000000000 0 4
0 1 1
2 0 2
3 0 3
4 1 0
4 2 0
3 4 0
 4 5 10 1 2
0 1 3
1 2 0
1 3 4
2 3 4
2 0 6
 4 4 2 1 3
1 3 13
2 3 0
2 0 0
1 0 0
 5 5 2 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 5 5 3 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 4 4 8 1 3
1 3 13
2 3 0
2 0 0
1 0 6
 1000 1 1000000000 998 0
0 999 0
 5 5 1 0 2
0 1 1
1 2 1
0 4 0
4 3 0
3 2 0
 100 1 123456 99 0
0 99 123456
 4 4 13 1 3
1 3 13
2 3 0
2 0 0
1 0 12
 7 9 319 0 3
0 1 0
1 2 0
2 3 0
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 1000 1 5 999 0
0 999 0

YES
0 1 1
1 2 999999996
2 3 999999997
0 4 1
4 1 1
1 5 499999999
5 2 499999999
2 6 1
6 3 1
 YES
0 1 1
1 2 199
2 3 318
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 1 3
1 2 3
2 3 2
0 2 5
1 3 5
 YES
1 2 1
2 4 1
1 3 1
3 4 1
4 5 6
5 6 1
6 0 1
5 7 1
7 0 1
 NO YES
0 1 1
2 0 2
3 0 3
4 1 999999999
4 2 999999998
3 4 999999997
 NO NO YES
0 1 1
1 2 1
0 4 1
4 3 1
3 2 1
 NO YES
1 3 13
2 3 1
2 0 1
1 0 6
 NO NO YES
0 99 123456
 YES
1 3 13
2 3 1
2 0 1
1 0 12
 YES
0 1 1
1 2 198
2 3 317
0 4 1
4 1 1
1 5 100
5 2 100
2 6 59
6 3 61
 YES
0 999 5

#include <bits/stdc++.h>
#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";
}
