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