#include <bits/stdc++.h>
using namespace std;
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
//#define f first
//#define s second
#define ll long long
#define mod 1000000007
#define N 1009
typedef map<pair<int,int>,ll> Mapp;
ll n,m,a,b,c,d,k,h,w,x,y,p,q,s,L,t,ans,res,ma,mi,T,act=0,pas=1,inf=1e18;
struct node
{
int x,w;
node(){}
node(int a,int b)
{
x=a;w=b;
}
};
vector<node> v[N];
vector<int> pre(N,0);
Mapp edges;
int zeroes[N];//min zeroes on path from s to i
struct node2
{
int x,p;
ll w;
node2(){}
node2(int a,ll c,int b)
{
x=a;p=b;
w=c;
}
};
struct cmp{
bool operator()(node2 a,node2 b)
{
return a.w>b.w;
}};
ll dijkstra()//fills pre
{
priority_queue<node2,vector<node2>,cmp> p;
ll h[N]={0};
node2 a=node2(s,0,-1);
p.push(a);
while(!p.empty())// not in same component
{
a=p.top();
p.pop();
if(!h[a.x])
{
pre[a.x]=a.p;
h[a.x]=a.w;
if(a.x==t){/*cout<<a.x<<" "<<t<<endl;*/return a.w;}
for(int i=0;i<v[a.x].size();i++)
{
int u=v[a.x][i].x;
if(u==a.x)continue;
if(h[u]==0)p.push(node2(u,a.w+v[a.x][i].w,a.x));
}
}
}
//cout<<"here"<<endl;
return L+1;
}
ll assign(int id,int z,ll len)
{
if(pre[id]==-1)return len;
int c=edges[mp(min(id,pre[id]),max(id,pre[id]))];
//cout<<"id="<<id<<" pre[id]="<<pre[id]<<" c="<<c<<" len="<<len<<endl;
if(c==0)
{
if(T==0)return inf;
T--;
edges[mp(min(id,pre[id]),max(id,pre[id]))]=1;
ll total=assign(pre[id],z+1,len+1);
if(total<T)
{
edges[mp(min(id,pre[id]),max(id,pre[id]))]+=T-total;
T=0;
}
//cout<<"id="<<id<<" total="<<total<<endl;
return max(L,total);
}
else
{
//T-=c;
ll total=assign(pre[id],z,len+c);
//cout<<"id="<<id<<" total="<<total<<endl;
return total;
}
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin>>n>>m>>L>>s>>t;
s++;t++;
T=L;
for(int i=0;i<m;i++)
{
cin>>a>>b>>c;
a++;b++;
v[a].pb(node(b,c));
v[b].pb(node(a,c));
edges[mp(min(a,b),max(a,b))]=c;
}
d=dijkstra();// fills pre
//cout<<d<<endl;
if(d>L){cout<<"NO";return 0;}
//backtrack();//fills zeroes[] using pre[]
//for(int i=0;i<=6;i++)cout<<pre[i]<<" ";cout<<endl;
d=assign(t,0,0);//using zeroes, reassigns edges.
//cout<<d<<endl;
if(d!=L){cout<<"NO";return 0;}
cout<<"YES"<<endl;
for(Mapp::iterator it=edges.begin();it!=edges.end();it++)
{
cout<<it->first.first-1<<" "<<it->first.second-1<<" ";
if(it->second==0)cout<<inf;
else cout<<it->second;
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgcGIoYSkgcHVzaF9iYWNrKGEpCiNkZWZpbmUgbXAoYSxiKSBtYWtlX3BhaXIoYSxiKQovLyNkZWZpbmUgZiBmaXJzdAovLyNkZWZpbmUgcyBzZWNvbmQKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBtb2QgMTAwMDAwMDAwNwojZGVmaW5lIE4gMTAwOQp0eXBlZGVmIG1hcDxwYWlyPGludCxpbnQ+LGxsPiBNYXBwOwpsbCBuLG0sYSxiLGMsZCxrLGgsdyx4LHkscCxxLHMsTCx0LGFucyxyZXMsbWEsbWksVCxhY3Q9MCxwYXM9MSxpbmY9MWUxODsKc3RydWN0IG5vZGUKewoJaW50IHgsdzsKCW5vZGUoKXt9Cglub2RlKGludCBhLGludCBiKQoJewoJCXg9YTt3PWI7Cgl9Cn07CnZlY3Rvcjxub2RlPiB2W05dOwp2ZWN0b3I8aW50PiBwcmUoTiwwKTsKTWFwcCBlZGdlczsKaW50IHplcm9lc1tOXTsvL21pbiB6ZXJvZXMgb24gcGF0aCBmcm9tIHMgdG8ga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