#include<bits/stdc++.h>
#define int long long
#define INF 2000000000
using namespace std;
int n,i,j,m,l,s,t,f[500000],first[500000],last[500000],next[500000],to[500000],c[500000],top=1;
int x,y,z;
bool change[500000],ontheway[500000],bo[500000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%I64d%I64d%I64d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	while(f[t]<l)
	{
		if(f[t]==l)
		{
			puts("YES");
			for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%I64d %I64d %I64d\n",i-1,to[j]-1,c[j]);
			return 0;
		}
		for(i=2;i<=top;i++)
		if(change[i]&&ontheway[i])
		{
			c[i]=c[i^1]=c[i]+l-f[t];
			break;
		}
		SPFA();

	}
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	while(f[t]<=l)
	{
		for(i=2;i<=top;i++)
		if(change[i]&&ontheway[i])
		{
			c[i]=c[i^1]=c[i]+l-f[t];
			SPFA();
			if(f[t]==l)break;
		}
	}
	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)
	if(change[i]&&ontheway[top])
	{
		c[i]=c[i^1]=c[i]+l-f[t];//change[i]=change[i^1]=false;
		SPFA();
		if(f[t]==l)break;
	}

	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)
	if(change[i]&&ontheway[i])
	{
		c[i]=c[i^1]=c[i]+l-f[t];//change[i]=change[i^1]=false;
		SPFA();
		if(f[t]==l)break;
	}

	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z,e[500000],etop;
bool change[50000],ontheway[50000],bo[50000];
vector <pair<int,int> > V;
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	etop=0;
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(change[i])etop++,e[etop]=i;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		if(z==0)
		{
			V.push_back(make_pair(x+1,y+1));
		}else
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	if(f[t]==l)
	{
		puts("YES");
		for(i=0;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}
	int pos=-1;
	for(i=0;i<V.size();i++)
	{
		add(V[i].first,V[i].second,1),add(V[i].second,V[i].first,1);
		SPFA();
		if(f[t]<=l)
		{
            c[top-1]+=l-f[t];
            c[top]+=l-f[t];
            pos=i;
            break;
        }
	}
	if(pos==-1)
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	for(i=pos+1;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
	for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);

	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000000
using namespace std;
int n,i,j,m,l,s,t,f[500000],first[500000],last[500000],next[500000],to[500000],c[500000],top=1;
int x,y,z;
bool change[500000],ontheway[500000],bo[500000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	for(int T=1;T<=1000;T++)
	{
		if(f[t]==l)
		{
			puts("YES");
			for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
			return 0;
		}
		for(i=2;i<=top;i++)
		if(change[i]&&ontheway[i])
		{
			c[i]=c[i^1]=c[i]+l-f[t];
			break;
		}
		SPFA();

	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define INF 100000000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z,e[500000],etop;
bool change[50000],bo[50000];
vector <pair<int,int> > V;
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);bo[s]=true;
	while(!q.empty())
	{
		int now=q.front();q.pop();bo[now]=false;
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

}
main()
{
	scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%I64d%I64d%I64d",&x,&y,&z);
		if(z==0)
		{
			V.push_back(make_pair(x+1,y+1));
		}else
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	if(f[t]==l)
	{
		puts("YES");
		for(i=0;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%I64d %I64d %I64d\n",i-1,to[j]-1,c[j]);
		return 0;
	}
	int pos=-1;
	for(i=0;i<V.size();i++)
	{
		add(V[i].first,V[i].second,1),add(V[i].second,V[i].first,1);
		SPFA();
		if(f[t]<=l)
		{
            c[top-1]+=l-f[t];
            c[top]+=l-f[t];
            pos=i;
            break;
        }
	}
	if(pos==-1)
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	for(i=pos+1;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
	for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%I64d %I64d %I64d\n",i-1,to[j]-1,c[j]);

	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z,e[500000],etop;
bool change[50000],ontheway[50000],bo[50000];
vector <pair<int,int> > V;
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	etop=0;
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(change[i])etop++,e[etop]=i;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		if(z==0)
		{
			V.push_back(make_pair(x+1,y+1));
		}else
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	int pos=-1;
	for(i=0;i<V.size();i++)
	{
		add(V[i].first,V[i].second,1),add(V[i].second,V[i].first,1);
		SPFA();
		if(f[t]<=l)
		{
            c[top-1]+=l-f[t];
            c[top]+=l-f[t];
            pos=i;
            break;
        }
	}
	if(pos==-1)
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	for(i=pos+1;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
	for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);

	return 0;
}


var
  a,first,last,next,b,c:array[0..1000000] of int64;
  n,m,l,s,t,i,j,x,y,z,k,h,tt:longint;
  top:longint;
  f,fa:array[0..1000000] of int64;
  q:array[1..1000000,1..2] of int64;
  bo:array[0..1000000] of boolean;
  function max(a,b:longint):int64;
  begin
    if a>b then exit(a) else exit(b);
  end;
procedure add(x,y,z:longint);
begin
  inc(k); a[k]:=y;b[k]:=z;c[k]:=x;//a->toit b->cap
  if first[x]=0 then first[x]:=k else next[last[x]]:=k;
  last[x]:=k;
  if b[k]=0 then bo[k]:=true;
end;
procedure push(x:longint);
begin
  inc(top);
  q[top,1]:=x;q[top,2]:=f[x];
end;
procedure spfa;
var
  x,i:longint;
begin
  top:=1;q[1,1]:=s;q[1,2]:=0;h:=0;
  for i:=0 to n do  f[i]:=1000000000000000;
  f[s]:=0;
  while h<top do

  begin
    inc(h);
    x:=first[q[h,1]];
    while x<>0 do
    begin
      if q[h,2]+b[x]<f[a[x]] then
      begin
        f[a[x]]:=q[h,2]+b[x];
        fa[a[x]]:=x;
        push(a[x]);
      end;
      x:=next[x];
    end;
  end;
 // until h>=top;
end;
begin
  readln(n,m,l,s,t);
  for i:=1 to m do begin readln(x,y,z); add(x,y,z); add(y,x,z); end;
  for i:=1 to k do if b[i]=0 then b[i]:=100000000000000;
  //==========================================================
  //for i:=1 to k do writeln(c[i],' ',a[i],' ',b[i]);
  //writeln(s,' ',t);
  spfa;
  //writeln(f[t]);
  if f[t]<l then begin write('NO'); halt; end;
  for i:=1 to k do if bo[i] then b[i]:=1;
  //==========================================================
  spfa;
  if f[t]>l then begin write('NO');halt;end;
 // writeln('p');
  while f[t]<>l do
  begin
    tt:=t;
    while not bo[fa[tt]] do tt:=c[fa[tt]];
    b[fa[tt]]:=l-f[t]+b[fa[tt]];
    spfa;
  end;
  writeln('YES');
  for i:=1 to m do writeln(a[(i-1)*2+2],' ',a[(i-1)*2+1],' ',max(b[(i-1)*2+1],b[(i-1)*2+2]))

  end.


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}

	for(i=2;i<=top;i++)
	if(change[i])
	{
		c[i]=c[i^1]=c[i]+l-f[t];
		SPFA();
		if(f[t]==l)break;
	}

	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z,e[500000],etop;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	etop=0;
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(change[i])etop++,e[etop]=i;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	while(f[t]<l)
	for(i=1;i<=etop;i++)
	if(change[e[i]])
	{
		c[e[i]]=c[e[i]^1]=c[e[i]]+l-f[t];change[e[i]]=change[e[i]^1]=false;
		SPFA();
		if(f[t]==l)break;
	}

	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define INF 2000000000
using namespace std;
int n,i,j,m,l,s,t,f[500000],first[500000],last[500000],next[500000],to[500000],c[500000],top=1;
int x,y,z;
bool change[500000],ontheway[500000],bo[500000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%I64d%I64d%I64d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	while(f[t]<=l)
	{
		if(f[t]==l)
		{
			puts("YES");
			for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%I64d %I64d %I64d\n",i-1,to[j]-1,c[j]);
			return 0;
		}
		for(i=2;i<=top;i++)
		if(change[i]&&ontheway[i])
		{
			c[i]=c[i^1]=c[i]+l-f[t];
			break;
		}
		SPFA();

	}
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	while(f[t]<l)
	for(i=2;i<=top;i++)
	if(change[i]&&ontheway[i])
	{
		c[i]=c[i^1]=c[i]+l-f[t];change[i]=change[i^1]=false;
		SPFA();
		if(f[t]==l)break;
	}

	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[500000],first[500000],last[500000],next[500000],to[500000],c[500000],top=1;
int x,y,z;
bool change[500000],ontheway[500000],bo[500000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	for(int T=1;T<=100;T++)
	{
		if(f[t]==l)
		{
			puts("YES");
			for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
			return 0;
		}
		for(i=2;i<=top;i++)
		if(change[i]&&ontheway[i])
		{
			c[i]=c[i^1]=c[i]+l-f[t];
			break;
		}
		SPFA();

	}
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}

	for(i=2;i<=top;i++)
	if(change[i]&&ontheway[i])
	{
		c[i]=c[i^1]=c[i]+l-f[t];
		SPFA();
		if(f[t]==l)break;
	}

	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	while(f[t]<l)
	{
		for(i=2;i<=top;i++)
		if(change[i]&&ontheway[i])
		{
			c[i]=c[i^1]=c[i]+l-f[t];
			SPFA();
			if(f[t]==l)break;
		}
	}
	if(f[t]==l)
	{
		puts("YES");
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
	}else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define INF 100000000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z,e[500000],etop;
bool change[50000],bo[50000];
vector <pair<int,int> > V;
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);bo[s]=true;
	while(!q.empty())
	{
		int now=q.front();q.pop();bo[now]=false;
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]>f[now]+c[i])
		{
			f[to[i]]=f[now]+c[i];
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

}
main()
{
	scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%I64d%I64d%I64d",&x,&y,&z);
		if(z==0)
		{
			V.push_back(make_pair(x+1,y+1));
		}else
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	if(f[t]==l)
	{
		puts("YES");
		for(i=0;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%I64d %I64d %I64d\n",i-1,to[j]-1,c[j]);
		return 0;
	}
	int pos=-1;
	for(i=0;i<V.size();i++)
	{
		add(V[i].first,V[i].second,1),add(V[i].second,V[i].first,1);
		SPFA();
		if(f[t]<=l)
		{
            c[top-1]+=l-f[t];
            c[top]+=l-f[t];
            pos=i;
            break;
        }
	}
	if(pos==-1)
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	for(i=pos+1;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
	for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%I64d %I64d %I64d\n",i-1,to[j]-1,c[j]);

	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z,e[500000],etop;
bool change[50000],ontheway[50000],bo[50000];
vector <pair<int,int> > V;
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	etop=0;
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(change[i])etop++,e[etop]=i;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		if(z==0)
		{
			V.push_back(make_pair(x+1,y+1));
		}else
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	if(f[t]==l)
	{
		puts("YES");
		for(i=0;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
		for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
		return 0;
	}
	int pos=-1;
	for(i=0;i<V.size();i++)
	{
		add(V[i].first,V[i].second,1),add(V[i].second,V[i].first,1);
		SPFA();
		if(f[t]<=l)
		{
            c[top-1]+=l-f[t];
            c[top]+=l-f[t];
            pos=i;
            break;
        }
	}
	if(pos==-1)
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	for(i=pos+1;i<V.size();i++)add(V[i].first,V[i].second,INF),add(V[i].second,V[i].first,INF);
	for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);

	return 0;
}


#include<bits/stdc++.h>
#define INF 1000000010
using namespace std;
int n,i,j,m,l,s,t,f[50000],first[50000],last[50000],next[50000],to[50000],c[50000],top=1;
int x,y,z;
bool change[50000],ontheway[50000],bo[50000];
void add(int x,int y,int z)
{
	top++,to[top]=y,c[top]=z;if(z==0)change[top]=true;
	if(first[x]==0)first[x]=top;else next[last[x]]=top;
	last[x]=top;
}
queue<int> q;
void SPFA()
{
	for(int i=1;i<=n;i++)f[i]=INF;memset(ontheway,0,sizeof(ontheway));memset(bo,0,sizeof(bo));
	f[s]=0;
	while(!q.empty())q.pop();
	q.push(s);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		{
			f[to[i]]=min(f[now]+c[i],f[to[i]]);
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}

	memset(bo,0,sizeof(bo));
	while(!q.empty())q.pop();
	q.push(t);
	while(!q.empty())
	{
		int now=q.front();q.pop();
		for(int i=first[now];i;i=next[i])
		if(f[to[i]]+c[i]==f[now])
		{
			ontheway[i]=ontheway[i^1]=true;
			if(!bo[to[i]])bo[to[i]]=true,q.push(to[i]);
		}
	}
}
main()
{
	scanf("%d%d%d%d%d",&n,&m,&l,&s,&t);s++,t++;
	for(i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		add(x+1,y+1,z),add(y+1,x+1,z);
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=INF;
	SPFA();
	if(f[t]<l)
	{
		puts("NO");
		return 0;
	}
	for(i=2;i<=top;i++)if(change[i])c[i]=1;
	SPFA();
	if(f[t]>l)
	{
		puts("NO");
		return 0;
	}
	while(f[t]<=l)
	{
		if(f[t]==l)
		{
			puts("YES");
			for(i=1;i<=n;i++)for(j=first[i];j;j=next[j])if(j%2)printf("%d %d %d\n",i-1,to[j]-1,c[j]);
			return 0;
		}
		for(i=2;i<=top;i++)
		if(change[i]&&ontheway[i])
		{
			c[i]=c[i^1]=c[i]+l-f[t];
			break;
		}
		SPFA();

	}
	return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
#define M 10005
#define INF (0x3f3f3f3f)
typedef long long ll;
const double PI = acos(-1.0);

struct edge
{
    int from,to,next;
    ll w;
}e[M*2];
int head[M];
bool vis[M];
int dist[M];
int t;
void add(int i,int j,ll w)
{
    e[t].from=i;
    e[t].to=j;
    e[t].w=w;
    e[t].next=head[i];
    head[i]=t++;
}
void spfa(int s)
{
    queue <int> q;
    for(int i=1;i<=M;i++)
        dist[i]=INF;
    memset(vis,false,sizeof(vis));
    q.push(s);
    vis[s] = true;//ppppp
    dist[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=e[i].next)
        {
            int v=e[i].to;
            if(dist[v]>dist[u]+e[i].w)//����ʼ��Ϊ-1����||dist[v]<0
            {
                dist[v]=dist[u]+e[i].w;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}
int n,m,s,tt;
ll l;
int mark[M];
int main()
{

    cin>>n>>m>>l>>s>>tt;
    memset(head,-1,sizeof(head));
    memset(mark,0,sizeof(mark));
    t=0;
    for(int i=0; i<m; i++)
    {
        int u,v;
        ll w;
        cin>>u>>v>>w;
        if(w==0)
        {
            w=1;
            mark[i]=1;
        }
        add(u,v,w);
        add(v,u,w);
    }
    spfa(s);
    int flag = 0;
    if(dist[tt]==INF||dist[tt]>l)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    else
    {
        ll dd = l - dist[tt];
        if(!dd)
            flag = 1;
        if(!flag)
        {
            for(int i=0; i<m; i++)
            {
                if(mark[i]==1)
                {
                    e[i*2].w+=dd;
                    e[i*2+1].w+=dd;
                    spfa(s);
                    if(dist[tt]==l)
                    {
                        flag =1;
                        break;
                    }
                    else
                    {
                        dd = l-dist[tt];
                    }
                }

            }
        }
        if(!flag)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(int i=0; i<m ;i++)
            {
                cout<<e[i*2].from<<" "<<e[i*2].to<<" "<<e[i*2].w<<endl;
            }
        }

    }

return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
#define M 10005
#define INF (0x3f3f3f3f)
typedef long long ll;
const double PI = acos(-1.0);

struct edge
{
    int from,to,next;
    ll w;
}e[M*2];
int head[M];
bool vis[M];
int dist[M];
int t;
void add(int i,int j,ll w)
{
    e[t].from=i;
    e[t].to=j;
    e[t].w=w;
    e[t].next=head[i];
    head[i]=t++;
}
void spfa(int s)
{
    queue <int> q;
    for(int i=1;i<=M;i++)
        dist[i]=INF;
    memset(vis,false,sizeof(vis));
    q.push(s);
    vis[s] = true;//ppppp
    dist[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=e[i].next)
        {
            int v=e[i].to;
            if(dist[v]>dist[u]+e[i].w)//����ʼ��Ϊ-1����||dist[v]<0
            {
                dist[v]=dist[u]+e[i].w;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}
int n,m,s,tt;
ll l;
int mark[M];
int main()
{

    cin>>n>>m>>l>>s>>tt;
    memset(head,-1,sizeof(head));
    memset(mark,0,sizeof(mark));
    t=0;
    for(int i=0; i<m; i++)
    {
        int u,v;
        ll w;
        cin>>u>>v>>w;
        if(w==0)
        {

            mark[i]=1;
        }
        add(u,v,w);
        add(v,u,w);
    }
    spfa(s);
    int flag = 0;
    if(dist[tt]==INF||dist[tt]>l)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    else
    {
        ll dd = l - dist[tt];
        if(!dd)
            flag = 1;
        if(!flag)
        {
            for(int i=0; i<m; i++)
            {
                if(mark[i]==1)
                {
                    e[i*2].w+=dd;
                    e[i*2+1].w+=dd;
                    spfa(s);
                    if(dist[tt]==l)
                    {
                        flag =1;
                        break;
                    }
                    else
                    {
                        dd = l-dist[tt];
                    }
                }

            }
        }
        if(!flag)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(int i=0; i<m ;i++)
            {
                cout<<e[i*2].from<<" "<<e[i*2].to<<" "<<e[i*2].w<<endl;
            }
        }

    }

return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
#define M 10005
#define INF (0x3f3f3f3f)
typedef long long ll;
const double PI = acos(-1.0);

struct edge
{
    int from,to,next;
    ll w;
}e[M*2];
int head[M];
bool vis[M];
int dist[M];
int t;
void add(int i,int j,ll w)
{
    e[t].from=i;
    e[t].to=j;
    e[t].w=w;
    e[t].next=head[i];
    head[i]=t++;
}
void spfa(int s)
{
    queue <int> q;
    for(int i=0;i<M;i++)//WA!.....(0,M-1)instead of (1,M)
        dist[i]=INF;
    memset(vis,false,sizeof(vis));
    q.push(s);
    vis[s] = true;//ppppp
    dist[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=e[i].next)
        {
            int v=e[i].to;
            if(dist[v]>dist[u]+e[i].w)
            {
                dist[v]=dist[u]+e[i].w;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}
int n,m,s,tt;
ll l;
int mark[M];
int main()
{

    cin>>n>>m>>l>>s>>tt;

    memset(head,-1,sizeof(head));
    memset(mark,0,sizeof(mark));
    t=0;
    for(int i=0; i<m; i++)
    {
        int u,v;
        ll w;
        cin>>u>>v>>w;
        if(w==0)
        {
            w=1;//not less than 1
            mark[i]=1;
        }
        add(u,v,w);
        add(v,u,w);
    }
    spfa(s);

    if(dist[tt]==INF||dist[tt]>l)
    {
        //cout<<dist[tt]<<endl;
        cout<<"NO"<<endl;
        return 0;
    }
    ll tmp = l-dist[tt];
    int flag = 0;
    if(dist[tt]==l)
        flag = 1;
    if(!flag)
    {
        for(int i=0; i<m; i++)
        {
            if(mark[i])
            {
                e[i*2].w+=tmp;
                e[i*2+1].w+=tmp;
                spfa(s);
                if(dist[tt]==l)
                {
                    flag = 1;
                    break;
                }
                else
                {
                    tmp = l-dist[tt];
                }
            }
        }
    }
    if(!flag)
        cout<<"NO"<<endl;
    else
    {
        cout<<"YES"<<endl;
        for(int i=0; i<m ;i++)
        {
            cout<<e[i*2].from<<" "<<e[i*2].to<<" "<<e[i*2].w<<endl;
        }
    }

return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
#define M 10005
#define INF (0x3f3f3f3f)
typedef long long ll;
const double PI = acos(-1.0);

struct edge
{
    int from,to,next;
    ll w;
}e[M*2];
int head[M];
bool vis[M];
int dist[M];
int t;
void add(int i,int j,ll w)
{
    e[t].from=i;
    e[t].to=j;
    e[t].w=w;
    e[t].next=head[i];
    head[i]=t++;
}
void spfa(int s)
{
    queue <int> q;
    for(int i=1;i<=M;i++)
        dist[i]=INF;
    memset(vis,false,sizeof(vis));
    q.push(s);
    vis[s] = true;//ppppp
    dist[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=e[i].next)
        {
            int v=e[i].to;
            if(dist[v]>dist[u]+e[i].w)//����ʼ��Ϊ-1����||dist[v]<0
            {
                dist[v]=dist[u]+e[i].w;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}
int n,m,s,tt;
ll l;
int mark[M];
int main()
{

    cin>>n>>m>>l>>s>>tt;
    if(s>tt)
        swap(s,tt);
    memset(head,-1,sizeof(head));
    memset(mark,0,sizeof(mark));
    t=0;
    for(int i=0; i<m; i++)
    {
        int u,v;
        ll w;
        cin>>u>>v>>w;
        if(w==0)
        {
            //w=1;////?????????
            mark[i]=1;
        }
        add(u,v,w);
        add(v,u,w);
    }
    spfa(s);
    int flag = 0;
    if(dist[tt]==INF||dist[tt]>l)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        ll dd = l - dist[tt];
        if(!dd)
            flag = 1;
        if(!flag)
        {
            for(int i=0; i<m; i++)
            {
                if(mark[i]==1)
                {
                    e[i*2].w+=dd;
                    e[i*2+1].w+=dd;
                    spfa(s);
                    if(dist[tt]==l)
                    {
                        flag =1;
                        //cout<<"loop"<<endl;
                        break;
                    }
                    else
                    {
                        dd = l-dist[tt];
                    }
                }

            }
        }
        if(!flag)
        {
            cout<<"NO"<<endl;

        }
        else
        {
            cout<<"YES"<<endl;
            for(int i=0; i<m ;i++)
            {
                if(e[i*2].w!=0)
                    cout<<e[i*2].from<<" "<<e[i*2].to<<" "<<e[i*2].w<<endl;
                else
                    cout<<e[i*2].from<<" "<<e[i*2].to<<" "<<"1000000000000000000"<<endl;
            }
        }

    }

return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
#define M 10005
#define INF (0x3f3f3f3f)
typedef long long ll;
const double PI = acos(-1.0);

struct edge
{
    int from,to,next;
    ll w;
}e[M*2];
int head[M];
bool vis[M];
int dist[M];
int t;
void add(int i,int j,ll w)
{
    e[t].from=i;
    e[t].to=j;
    e[t].w=w;
    e[t].next=head[i];
    head[i]=t++;
}
void spfa(int s)
{
    queue <int> q;
    for(int i=1;i<=M;i++)
        dist[i]=INF;
    memset(vis,false,sizeof(vis));
    q.push(s);
    vis[s] = true;//ppppp
    dist[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=e[i].next)
        {
            int v=e[i].to;
            if(dist[v]>dist[u]+e[i].w)//����ʼ��Ϊ-1����||dist[v]<0
            {
                dist[v]=dist[u]+e[i].w;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}
int n,m,s,tt;
ll l;
int mark[M];
int main()
{

    cin>>n>>m>>l>>s>>tt;
    if(s>tt)
        swap(s,tt);
    memset(head,-1,sizeof(head));
    memset(mark,0,sizeof(mark));
    t=0;
    for(int i=0; i<m; i++)
    {
        int u,v;
        ll w;
        cin>>u>>v>>w;
        if(w==0)
        {
            //w=1;////?????????
            mark[i]=1;
        }
        add(u,v,w);
        add(v,u,w);
    }
    spfa(s);
    int flag = 0;
    if(dist[tt]==INF||dist[tt]>l)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        ll dd = l - dist[tt];
        if(!dd)
            flag = 1;
        if(!flag)
        {
            for(int i=0; i<m; i++)
            {
                if(mark[i]==1)
                {
                    e[i*2].w+=dd;
                    e[i*2+1].w+=dd;
                    spfa(s);
                    if(dist[tt]==l)
                    {
                        flag =1;
                        //cout<<"loop"<<endl;
                        break;
                    }
                    else
                    {
                        dd = l-dist[tt];
                    }
                }

            }
        }
        if(!flag)
        {
            cout<<"NO"<<endl;

        }
        else
        {
            cout<<"YES"<<endl;
            for(int i=0; i<m ;i++)
            {
                cout<<e[i*2].from<<" "<<e[i*2].to<<" "<<e[i*2].w<<endl;
            }
        }

    }

return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
#define M 10005
#define INF (0x3f3f3f3f)
typedef long long ll;
const double PI = acos(-1.0);

struct edge
{
    int from,to,next;
    ll w;
}e[M*2];
int head[M];
bool vis[M];
int dist[M];
int t;
void add(int i,int j,ll w)
{
    e[t].from=i;
    e[t].to=j;
    e[t].w=w;
    e[t].next=head[i];
    head[i]=t++;
}
void spfa(int s)
{
    queue <int> q;
    for(int i=1;i<=M;i++)
        dist[i]=INF;
    memset(vis,false,sizeof(vis));
    q.push(s);
    vis[s] = true;//ppppp
    dist[s]=0;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=false;
        for(int i=head[u];i!=-1;i=e[i].next)
        {
            int v=e[i].to;
            if(dist[v]>dist[u]+e[i].w)//����ʼ��Ϊ-1����||dist[v]<0
            {
                dist[v]=dist[u]+e[i].w;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
}
int n,m,s,tt;
ll l;
int mark[M];
int main()
{

    cin>>n>>m>>l>>s>>tt;
    memset(head,-1,sizeof(head));
    memset(mark,0,sizeof(mark));
    t=0;
    for(int i=0; i<m; i++)
    {
        int u,v;
        ll w;
        cin>>u>>v>>w;
        if(w==0)
        {
            w=0.1;
            mark[i]=1;
        }
        add(u,v,w);
        add(v,u,w);
    }
    spfa(s);
    int flag = 0;
    if(dist[tt]==INF||dist[tt]>l)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    else
    {
        ll dd = l - dist[tt];
        if(!dd)
            flag = 1;
        if(!flag)
        {
            for(int i=0; i<m; i++)
            {
                if(mark[i]==1)
                {
                    e[i*2].w+=dd;
                    e[i*2+1].w+=dd;
                    spfa(s);
                    if(dist[tt]==l)
                    {
                        flag =1;
                        break;
                    }
                    else
                    {
                        dd = l-dist[tt];
                    }
                }

            }
        }
        if(!flag)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(int i=0; i<m ;i++)
            {
                cout<<e[i*2].from<<" "<<e[i*2].to<<" "<<e[i*2].w<<endl;
            }
        }

    }

return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int N = 1001;
const int M = 10001;
const ll INF = ll(1e18);

vector<ii> adj[N];
vector<int> adj2[N];
int L[M]; int R[M];
ll d1[N];
ll d2[N];
int par[N];
ll dist[N][N];

int n, m, l, s, e;
int dist1[N][N];

void dijkstra(){
	d1[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	int cnt=0;
	while(!q.empty()){
		/*int temp=10000;
		while(temp--);
		cout<<cnt++<<"\n";*/
		ll u=q.front().se;ll d=q.front().fi; q.pop();
		for(int i=0;i<adj[u].size();i++){
			int v=adj[u][i].fi;ll w=adj[u][i].se;
			if(d + w < d1[v]){
				d1[v]=d + w;
				q.push(ii(d1[v],v));
			}
		}
	}
}

bool dijkstra2(){
	d2[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	while(!q.empty()){
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	//cout<<"finish1\n";
	if(d2[e] > l) return false;
	int cur = e;
	while(cur!=s){
		int p=par[cur];
		if(dist[p][cur]<0){
			dist[p][cur]=-2;dist[cur][p]=-2;
		}
		cur=par[cur];
	}
	//cout<<"finish1\n";
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] == -1)
			{
				dist[i][j] = INF;
			}
		}
	}
	cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -1; dist[cur][p] = -1;
		}
		cur = par[cur];
	}
	return true;

}

bool relax(){
	for(int i = 0; i < n; i++) d2[i] = INF;
	d2[s] = 0;
	queue <ii> q;
	q.push(ii(0, s));
	while(!q.empty())
	{
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	if(d2[e] == l) return true;
	int cur=e;bool meet=false;
	while(cur != s ){
		int p=par[cur];
		if(!meet && dist[p][cur]<0){
			ll d=abs(dist[p][cur]);
			dist[p][cur]=l+d-d2[e];
			dist[cur][p]=l+d-d2[e];
			meet=true;
		}
		if(meet) break;
		cur=par[cur];
	}
	return false;
}

void print()
{
	cout << "YES\n";
	for(int i = 0; i < m; i++)
	{
		int u = L[i]; int v = R[i];
		ll d = dist[u][v];
		if(d < 0) d = -d;
		cout << u << ' ' << v << ' ' << d << '\n';
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> l >> s >> e;
	memset(dist1, -1, sizeof(dist1));
	for(int i = 0; i < m; i++)
	{
	//	cout<<"started\n";
		int u, v, w; cin>>u>>v>>w;
		if(w > 0)
		{
			adj[u].pb(ii(v, w)); adj[v].pb(ii(u, w));
			adj2[u].pb(v); adj2[v].pb(u);
			dist1[u][v] = w; dist1[v][u] = w;
			dist[u][v] = w; dist[v][u] = w;
		}
		else
		{
			adj2[u].pb(v); adj2[v].pb(u);
			dist[u][v] = -1; dist[v][u] = -1;
		}
		L[i] = u; R[i] = v;
	}
	//cout<<"ended\n";
	for(int i = 0; i < n; i++)
	{
		d1[i] = INF; d2[i] = INF;
	}

	//cout<<"dijkstra called\n";
	dijkstra();
	//cout<<"dijkstra ended\n";

	if(d1[e]<l){
		cout<<"NO\n";
		return 0;
	}
	if(d1[e]==l){
		cout<<"YES\n";
		for(int i = 0; i < m; i++)
		{
			int u = L[i]; int v = R[i];
			ll d = dist1[u][v];
			if(d <= 0) d = INF;
			cout << u << ' ' << v << ' ' << d << '\n';
		}
		return 0;
	}
	//cout<<"dijkstra called\n";
	bool tmp=dijkstra2();
	//cout<<"dijkstra called\n";
	if(!tmp){
		cout<<"NO\n";
		return 0;
	}
	int cnt = 0;
	//cout<<"print called\n";
	while(!relax())
	{
		relax(); cnt++;
	//	cout<<cnt<<"\n";
	}
	//cout<<"print called\n";
	print();
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int N = 1001;
const int M = 10001;
const ll INF = ll(1e18);

vector<ii> adj[N];
vector<int> adj2[N];
int L[M]; int R[M];
ll d1[N];
ll d2[N];
int par[N];
ll dist[N][N];

int n, m, l, s, e;
int dist1[N][N];

void dijkstra(){
	d1[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	int cnt=0;
	while(!q.empty()){
		/*int temp=10000;
		while(temp--);
		cout<<cnt++<<"\n";*/
		ll u=q.front().se;ll d=q.front().fi; q.pop();
		for(int i=0;i<adj[u].size();i++){
			int v=adj[u][i].fi;ll w=adj[u][i].se;
			if(d + w < d1[v]){
				d1[v]=d + w;
				q.push(ii(d1[v],v));
			}
		}
	}
}

bool dijkstra2(){
	d2[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	while(!q.empty()){
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	//cout<<"finish1\n";
	if(d2[e] > l) return false;
	int cur = e;
	while(cur!=s){
		int p=par[cur];
		if(dist[p][cur]<0){
			dist[p][cur]=-2;dist[cur][p]=-2;
		}
		cur=par[cur];
	}
	//cout<<"finish1\n";
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] == -1)
			{
				dist[i][j] = INF;
			}
		}
	}
	cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -1; dist[cur][p] = -1;
		}
		cur = par[cur];
	}
	return true;

}

bool relax(){
	for(int i = 0; i < n; i++) d2[i] = INF;
	d2[s] = 0;
	queue <ii> q;
	q.push(ii(0, s));
	while(!q.empty())
	{
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	if(d2[e] == l) return true;
	int cur=e;bool meet=false;
	while(cur != s ){
		int p=par[cur];
		if(!meet && dist[p][cur]<0){
			ll d=abs(dist[p][cur]);
			dist[p][cur]=l+d-d2[e];
			dist[cur][p]=l+d-d2[e];
			meet=true;
		}
		if(meet) break;
		cur=par[cur];
	}
	return false;
}

void print()
{
	cout << "YES\n";
	for(int i = 0; i < m; i++)
	{
		int u = L[i]; int v = R[i];
		ll d = dist[u][v];
		if(d < 0) d = -d;
		cout << u << ' ' << v << ' ' << d << '\n';
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> l >> s >> e;
	//memset(dist1, -1, sizeof(dist1));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++)
			dist1[i][j]=-1;
	}
	for(int i = 0; i < m; i++)
	{
	//	cout<<"started\n";
		int u, v, w; cin>>u>>v>>w;
		if(w > 0)
		{
			adj[u].pb(ii(v, w)); adj[v].pb(ii(u, w));
			adj2[u].pb(v); adj2[v].pb(u);
			dist1[u][v] = w; dist1[v][u] = w;
			dist[u][v] = w; dist[v][u] = w;
		}
		else
		{
			adj2[u].pb(v); adj2[v].pb(u);
			dist[u][v] = -1; dist[v][u] = -1;
		}
		L[i] = u; R[i] = v;
	}
	//cout<<"ended\n";
	for(int i = 0; i < n; i++)
	{
		d1[i] = INF; d2[i] = INF;
	}

	//cout<<"dijkstra called\n";
	dijkstra();
	//cout<<"dijkstra ended\n";

	if(d1[e]<l){
		cout<<"NO\n";
		return 0;
	}
	if(d1[e]==l){
		cout<<"YES\n";
		for(int i = 0; i < m; i++)
		{
			int u = L[i]; int v = R[i];
			ll d = dist1[u][v];
			if(d <= 0) d = INF;
			cout << u << ' ' << v << ' ' << d << '\n';
		}
		return 0;
	}
	//cout<<"dijkstra called\n";
	bool tmp=dijkstra2();
	//cout<<"dijkstra called\n";
	if(!tmp){
		cout<<"NO\n";
		return 0;
	}
	int cnt = 0;
	//cout<<"print called\n";
	while(!relax())
	{
		relax(); cnt++;
	//	cout<<cnt<<"\n";
	}
	//cout<<"print called\n";
	print();
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int N = 1001;
const int M = 10001;
const ll INF = ll(1e18);

vector<ii> adj[N];
vector<int> adj2[N];
int L[M]; int R[M];
ll d1[N];
ll d2[N];
int par[N];
ll dist[N][N];

int n, m, l, s, e;

void dijkstra()
{
	d1[s] = 0;
	priority_queue<ii, vector<ii>, greater<ii> > pq;
	pq.push(ii(0, s));
	int cnt = 0;
	while(!pq.empty())
	{
		cnt++;
		int u = pq.top().se; ll d = pq.top().fi; pq.pop();
		for(int i = 0; i < adj[u].size(); i++)
		{
			int v = adj[u][i].fi; ll w = adj[u][i].se;
			if(d + w < d1[v])
			{
				d1[v] = d + w;
				pq.push(ii(d1[v], v));
			}
		}
	}
	cerr << "DIJKSTRA OPERATIONS : " << cnt << '\n';
}

bool dijkstra2()
{
	d2[s] = 0;
	priority_queue<ii, vector<ii>, greater<ii> > pq;
	pq.push(ii(0, s));
	while(!pq.empty())
	{
		int u = pq.top().se; ll d = pq.top().fi; pq.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				pq.push(ii(d2[v], v));
			}
		}
	}
	if(d2[e] > l) return false;
	int cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -2; dist[cur][p] = -2;
		}
		cur = par[cur];
	}
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] == -1)
			{
				dist[i][j] = INF;
			}
		}
	}
	cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -1; dist[cur][p] = -1;
		}
		cur = par[cur];
	}
	return true;
}

void print()
{
	cout << "YES\n";
	for(int i = 0; i < m; i++)
	{
		int u = L[i]; int v = R[i];
		ll d = dist[u][v];
		if(d < 0) d = -d;
		cout << u << ' ' << v << ' ' << d << '\n';
	}
}

bool relax()
{
	for(int i = 0; i < n; i++) d2[i] = INF;
	memset(par, -1, sizeof(par)); //shouldn't be neccesary
	d2[s] = 0;
	priority_queue<ii, vector<ii>, greater<ii> > pq;
	pq.push(ii(0, s));
	while(!pq.empty())
	{
		int u = pq.top().se; ll d = pq.top().fi; pq.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				pq.push(ii(d2[v], v));
			}
		}
	}
	//cerr << d2[e] << '\n';
	if(d2[e] == l) return true;
	int cur = e; bool meet = false;
	while(cur != s)
	{
		int p = par[cur];
		if(!meet && dist[p][cur] < 0)
		{
			ll d = abs(dist[p][cur]);
			dist[p][cur] = d + l - d2[e];
			dist[cur][p] = d + l - d2[e];
			//cerr << d << endl;
			meet = true;
		}
		if(meet) break;
		cur = par[cur];
	}
	return false;
}

int dist1[N][N];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> l >> s >> e;
	memset(dist1, -1, sizeof(dist1));
	for(int i = 0; i < m; i++)
	{
		int u, v, w; cin >> u >> v >> w;
		if(w > 0)
		{
			adj[u].pb(ii(v, w)); adj[v].pb(ii(u, w));
			adj2[u].pb(v); adj2[v].pb(u);
			dist1[u][v] = w; dist1[v][u] = w;
			dist[u][v] = w; dist[v][u] = w;
		}
		else
		{
			adj2[u].pb(v); adj2[v].pb(u);
			dist[u][v] = -1; dist[v][u] = -1;
		}
		L[i] = u; R[i] = v;
	}
	for(int i = 0; i < n; i++)
	{
		d1[i] = INF; d2[i] = INF;
	}
	dijkstra(); //cerr << d1[e] << '\n';
	if(d1[e] < l)
	{
		cout << "NO\n";
		return 0;
	}
	if(d1[e] == l)
	{
		cout << "YES\n";
		for(int i = 0; i < m; i++)
		{
			int u = L[i]; int v = R[i];
			ll d = dist1[u][v];
			if(d <= 0) d = INF;
			cout << u << ' ' << v << ' ' << d << '\n';
		}
		return 0;
	}
	bool tmp = dijkstra2();
	if(!tmp)
	{
		cout << "NO\n";
		return 0;
	}
	//cerr << d2[e] << '\n';
	int cnt = 0;
	while(!relax())
	{
		relax(); cnt++;
	}
	cerr << "RELAXATIONS DONE : " << cnt << '\n';
	print();
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int N = 1001;
const int M = 10001;
const ll INF = ll(1e18);

vector<ii> adj[N];
vector<int> adj2[N];
int L[M]; int R[M];
ll d1[N];
ll d2[N];
int par[N];
ll dist[N][N];

int n, m, l, s, e;
int dist1[N][N];

void dijkstra(){
	d1[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	int cnt=0;
	while(!q.empty()){
		/*int temp=10000;
		while(temp--);
		cout<<cnt++<<"\n";*/
		ll u=q.front().se;ll d=q.front().fi; q.pop();
		for(int i=0;i<adj[u].size();i++){
			int v=adj[u][i].fi;ll w=adj[u][i].se;
			if(d + w < d1[v]){
				d1[v]=d + w;
				q.push(ii(d1[v],v));
			}
		}
	}
}

bool dijkstra2(){
	d2[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	while(!q.empty()){
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	//cout<<"finish1\n";
	if(d2[e] > l) return false;
	int cur = e;
	while(cur!=s){
		int p=par[cur];
		if(dist[p][cur]<0){
			dist[p][cur]=-2;dist[cur][p]=-2;
		}
		cur=par[cur];
	}
	//cout<<"finish1\n";
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] == -1)
			{
				dist[i][j] = INF;
			}
		}
	}
	cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -1; dist[cur][p] = -1;
		}
		cur = par[cur];
	}
	return true;

}

bool relax(){
	for(int i = 0; i < n; i++) d2[i] = INF;
	d2[s] = 0;
	queue <ii> q;
	q.push(ii(0, s));
	while(!q.empty())
	{
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	if(d2[e] == l) return true;
	int cur=e;bool meet=false;
	while(cur != s ){
		int p=par[cur];
		if(!meet && dist[p][cur]<0){
			ll d=abs(dist[p][cur]);
			dist[p][cur]=l+d-d2[e];
			dist[cur][p]=l+d-d2[e];
			meet=true;
		}
		if(meet) break;
		cur=par[cur];
	}
	return false;
}

void print()
{
	cout << "YES\n";
	for(int i = 0; i < m; i++)
	{
		int u = L[i]; int v = R[i];
		ll d = dist[u][v];
		if(d < 0) d = -d;
		cout << u << ' ' << v << ' ' << d << '\n';
	}
}

int main(){
	cin >> n >> m >> l >> s >> e;
	//memset(dist1, -1, sizeof(dist1));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++)
			dist1[i][j]=-1;
	}
	for(int i = 0; i < m; i++)
	{
	//	cout<<"started\n";
		int u, v, w; scanf("%d%d%d",&u,&v,&w);
		if(w > 0)
		{
			adj[u].pb(ii(v, w)); adj[v].pb(ii(u, w));
			adj2[u].pb(v); adj2[v].pb(u);
			dist1[u][v] = w; dist1[v][u] = w;
			dist[u][v] = w; dist[v][u] = w;
		}
		else
		{
			adj2[u].pb(v); adj2[v].pb(u);
			dist[u][v] = -1; dist[v][u] = -1;
		}
		L[i] = u; R[i] = v;
	}
	//cout<<"ended\n";
	for(int i = 0; i < n; i++)
	{
		d1[i] = INF; d2[i] = INF;
	}

	//cout<<"dijkstra called\n";
	dijkstra();
	//cout<<"dijkstra ended\n";

	if(d1[e]<l){
		cout<<"NO\n";
		return 0;
	}
	if(d1[e]==l){
		cout<<"YES\n";
		for(int i = 0; i < m; i++)
		{
			int u = L[i]; int v = R[i];
			ll d = dist1[u][v];
			if(d <= 0) d = INF;
			cout << u << ' ' << v << ' ' << d << '\n';
		}
		return 0;
	}
	//cout<<"dijkstra called\n";
	bool tmp=dijkstra2();
	//cout<<"dijkstra called\n";
	if(!tmp){
		cout<<"NO\n";
		return 0;
	}
	int cnt = 0;
	//cout<<"print called\n";
	while(!relax())
	{
		relax(); cnt++;
	//	cout<<cnt<<"\n";
	}
	//cout<<"print called\n";
	print();
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int N = 1001;
const int M = 10001;
const ll INF = ll(1e18);

vector<ii> adj[N];
vector<int> adj2[N];
int L[M]; int R[M];
ll d1[N];
ll d2[N];
int par[N];
ll dist[N][N];

int n, m, l, s, e;
int dist1[N][N];

void dijkstra(){
	d1[s]=0;
	priority_queue<ii, vector<ii>, greater<ii> > q;
	q.push(ii(0,s));
	int cnt=0;
	while(!q.empty()){
		/*int temp=10000;
		while(temp--);
		cout<<cnt++<<"\n";*/
		int u = q.top().se; ll d = q.top().fi; q.pop();
		for(int i=0;i<adj[u].size();i++){
			int v=adj[u][i].fi;ll w=adj[u][i].se;
			if(d + w < d1[v]){
				d1[v]=d + w;
				q.push(ii(d1[v],v));
			}
		}
	}
}

bool dijkstra2(){
	d2[s]=0;
	priority_queue<ii, vector<ii>, greater<ii> > q;
	q.push(ii(0,s));
	while(!q.empty()){
		int u = q.top().se; ll d = q.top().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	//cout<<"finish1\n";
	if(d2[e] > l) return false;
	int cur = e;
	while(cur!=s){
		int p=par[cur];
		if(dist[p][cur]<0){
			dist[p][cur]=-2;dist[cur][p]=-2;
		}
		cur=par[cur];
	}
	//cout<<"finish1\n";
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] == -1)
			{
				dist[i][j] = INF;
			}
		}
	}
	cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -1; dist[cur][p] = -1;
		}
		cur = par[cur];
	}
	return true;

}

bool relax(){
	for(int i = 0; i < n; i++) d2[i] = INF;
	d2[s] = 0;
	priority_queue<ii, vector<ii>, greater<ii> > q;
	q.push(ii(0, s));
	while(!q.empty())
	{
		int u = q.top().se; ll d = q.top().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	if(d2[e] == l) return true;
	int cur=e;bool meet=false;
	while(cur != s ){
		int p=par[cur];
		if(!meet && dist[p][cur]<0){
			ll d=abs(dist[p][cur]);
			dist[p][cur]=l+d-d2[e];
			dist[cur][p]=l+d-d2[e];
			meet=true;
		}
		if(meet) break;
		cur=par[cur];
	}
	return false;
}

void print()
{
	cout << "YES\n";
	for(int i = 0; i < m; i++)
	{
		int u = L[i]; int v = R[i];
		ll d = dist[u][v];
		if(d < 0) d = -d;
		cout << u << ' ' << v << ' ' << d << '\n';
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> l >> s >> e;
	memset(dist1, -1, sizeof(dist1));
	for(int i = 0; i < m; i++)
	{
	//	cout<<"started\n";
		int u, v, w; cin>>u>>v>>w;
		if(w > 0)
		{
			adj[u].pb(ii(v, w)); adj[v].pb(ii(u, w));
			adj2[u].pb(v); adj2[v].pb(u);
			dist1[u][v] = w; dist1[v][u] = w;
			dist[u][v] = w; dist[v][u] = w;
		}
		else
		{
			adj2[u].pb(v); adj2[v].pb(u);
			dist[u][v] = -1; dist[v][u] = -1;
		}
		L[i] = u; R[i] = v;
	}
	//cout<<"ended\n";
	for(int i = 0; i < n; i++)
	{
		d1[i] = INF; d2[i] = INF;
	}

	//cout<<"dijkstra called\n";
	dijkstra();
	//cout<<"dijkstra ended\n";

	if(d1[e]<l){
		cout<<"NO\n";
		return 0;
	}
	if(d1[e]==l){
		cout<<"YES\n";
		for(int i = 0; i < m; i++)
		{
			int u = L[i]; int v = R[i];
			ll d = dist1[u][v];
			if(d <= 0) d = INF;
			cout << u << ' ' << v << ' ' << d << '\n';
		}
		return 0;
	}
	//cout<<"dijkstra called\n";
	bool tmp=dijkstra2();
	//cout<<"dijkstra called\n";
	if(!tmp){
		cout<<"NO\n";
		return 0;
	}
	//cout<<"print called\n";
	while(!relax())
	{
		relax();
	//	cout<<cnt<<"\n";
	}
	//cout<<"print called\n";
	print();
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int N = 1001;
const int M = 10001;
const ll INF = ll(1e18);

vector<ii> adj[N];
vector<int> adj2[N];
int L[M]; int R[M];
ll d1[N];
ll d2[N];
int par[N];
ll dist[N][N];

int n, m, l, s, e;
int dist1[N][N];

void dijkstra(){
	d1[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	int cnt=0;
	while(!q.empty()){
		/*int temp=10000;
		while(temp--);
		cout<<cnt++<<"\n";*/
		ll u=q.front().se;ll d=q.front().fi; q.pop();
		for(int i=0;i<adj[u].size();i++){
			int v=adj[u][i].fi;ll w=adj[u][i].se;
			if(d + w < d1[v]){
				d1[v]=d + w;
				q.push(ii(d1[v],v));
			}
		}
	}
}

bool dijkstra2(){
	d2[s]=0;
	queue <ii> q;
	q.push(ii(0,s));
	while(!q.empty()){
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	//cout<<"finish1\n";
	if(d2[e] > l) return false;
	int cur = e;
	while(cur!=s){
		int p=par[cur];
		if(dist[p][cur]<0){
			dist[p][cur]=-2;dist[cur][p]=-2;
		}
		cur=par[cur];
	}
	//cout<<"finish1\n";
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(dist[i][j] == -1)
			{
				dist[i][j] = INF;
			}
		}
	}
	cur = e;
	while(cur != s)
	{
		int p = par[cur];
		if(dist[p][cur] < 0)
		{
			dist[p][cur] = -1; dist[cur][p] = -1;
		}
		cur = par[cur];
	}
	return true;

}

bool relax(){
	for(int i = 0; i < n; i++) d2[i] = INF;
	d2[s] = 0;
	queue <ii> q;
	q.push(ii(0, s));
	while(!q.empty())
	{
		int u = q.front().se; ll d = q.front().fi; q.pop();
		for(int i = 0; i < adj2[u].size(); i++)
		{
			int v = adj2[u][i]; ll w = dist[u][v];
			if(d + abs(w) < d2[v])
			{
				d2[v] = d + abs(w);
				par[v] = u;
				q.push(ii(d2[v], v));
			}
		}
	}
	if(d2[e] == l) return true;
	int cur=e;bool meet=false;
	while(cur != s ){
		int p=par[cur];
		if(!meet && dist[p][cur]<0){
			ll d=abs(dist[p][cur]);
			dist[p][cur]=l+d-d2[e];
			dist[cur][p]=l+d-d2[e];
			meet=true;
		}
		if(meet) break;
		cur=par[cur];
	}
	return false;
}

void print()
{
	cout << "YES\n";
	for(int i = 0; i < m; i++)
	{
		int u = L[i]; int v = R[i];
		ll d = dist[u][v];
		if(d < 0) d = -d;
		cout << u << ' ' << v << ' ' << d << '\n';
	}
}

int main(){
	cin >> n >> m >> l >> s >> e;
	//memset(dist1, -1, sizeof(dist1));
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++)
			dist1[i][j]=-1;
	}
	for(int i = 0; i < m; i++)
	{
	//	cout<<"started\n";
		int u, v, w; cin >> u >> v >> w;
		if(w > 0)
		{
			adj[u].pb(ii(v, w)); adj[v].pb(ii(u, w));
			adj2[u].pb(v); adj2[v].pb(u);
			dist1[u][v] = w; dist1[v][u] = w;
			dist[u][v] = w; dist[v][u] = w;
		}
		else
		{
			adj2[u].pb(v); adj2[v].pb(u);
			dist[u][v] = -1; dist[v][u] = -1;
		}
		L[i] = u; R[i] = v;
	}
	//cout<<"ended\n";
	for(int i = 0; i < n; i++)
	{
		d1[i] = INF; d2[i] = INF;
	}

	//cout<<"dijkstra called\n";
	dijkstra();
	//cout<<"dijkstra ended\n";

	if(d1[e]<l){
		cout<<"NO\n";
		return 0;
	}
	if(d1[e]==l){
		cout<<"YES\n";
		for(int i = 0; i < m; i++)
		{
			int u = L[i]; int v = R[i];
			ll d = dist1[u][v];
			if(d <= 0) d = INF;
			cout << u << ' ' << v << ' ' << d << '\n';
		}
		return 0;
	}
	//cout<<"dijkstra called\n";
	bool tmp=dijkstra2();
	//cout<<"dijkstra called\n";
	if(!tmp){
		cout<<"NO\n";
		return 0;
	}
	int cnt = 0;
	//cout<<"print called\n";
	while(!relax())
	{
		relax(); cnt++;
	//	cout<<cnt<<"\n";
	}
	//cout<<"print called\n";
	print();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 100050;

int dt[N][3], pre[N];
int n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{int next,to,w,from;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    int dis,id;
    node(){}
    node(int _,int __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(int u,int v,int w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

int dij(int u,int v)
{
    priority_queue<node> q;
    node ahead, next;
    int i;

    q.push(node(0,u));
    memset(dis,0x3f,sizeof(dis));
    dis[u] = 0; inq[0] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    int i, x, y, z, Qans;
    scanf("%d%d%d%d%d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%d%d%d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%d %d 1\n",dt[i][0],dt[i][1]);
    		else printf("%d %d %d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) i = pre[e[i].from], y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%d %d %d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%d %d %d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;
const LL inf = 1000000000000000000LL;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = inf;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                if(!inq[next.id]) {q.push(next), inq[next.id] = true;}
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	cnt = 0;
	memset(head,0,sizeof(head));
	for(i = 1; i <= m; ++ i) if(dt[i][2]) link(dt[i][0],dt[i][1],dt[i][2]);
	x = -1;
	for(i = 1; i <= m; ++ i)
		if(!dt[i][2])
		{
			link(dt[i][0],dt[i][1],1);
			Qans = dij(s,t);
			if(Qans <= L) {x = i; break;}
		}
	if(x == -1){puts("NO"); return 0;}
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0)
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], i == x ? L - Qans + 1 : inf);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const int N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{int next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	int id;
    node(){}
    node(LL _,int __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(int u,int v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

int dij(int u,int v)
{
    priority_queue<node> q;
    node ahead, next;
    int i;

    q.push(node(0,u));
    for(i = 1; i <= n; ++ i) dis[i] = 1LL<<61;
    dis[u] = 0; inq[0] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 1\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) i = pre[e[i].from], y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1e15;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 0;
	while(e[i].from != s) {y += (e[i].w == 1 && ok[e[i].from][e[i].to]); if((e[i].w == 1 && ok[e[i].from][e[i].to])) x = i; i = pre[e[i].from]; }
	y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;
const LL inf = 1000000000000000000LL;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = inf;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                if(!inq[next.id]) {q.push(next), inq[next.id] = true;}
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	cnt = 0;
	memset(head,0,sizeof(head));
	for(i = 1; i <= m; ++ i) if(dt[i][2]) link(dt[i][0],dt[i][1],dt[i][2]);
	x = -1;
	for(i = 1; i <= m; ++ i)
		if(!dt[i][2])
		{
			link(dt[i][0],dt[i][1],1);
			Qans = dij(s,t);
			if(Qans < L) {x = i; break;}
		}
	if(x == -1){puts("NO"); return 0;}
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0)
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], i == x ? L - Qans + 1 : inf);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1LL<<61;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) i = pre[e[i].from], y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const int N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{int next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	int id;
    node(){}
    node(LL _,int __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(int u,int v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(int u,int v)
{
    priority_queue<node> q;
    node ahead, next;
    int i;

    q.push(node(0,u));
    for(i = 1; i <= n; ++ i) dis[i] = 1LL<<61;
    dis[u] = 0; inq[0] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 1\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) i = pre[e[i].from], y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 1; i <= n; ++ i) dis[i] = 1LL<<61;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 1\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) i = pre[e[i].from], y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 1; i <= n; ++ i) dis[i] = 1LL<<61;
    dis[u] = 0; inq[0] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 1\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) i = pre[e[i].from], y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1LL<<61;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                pre[next.id] = i;
                if(!inq[next.id]) q.push(next), inq[next.id] = true;
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 1\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 1;
	while(e[i].from != s) i = pre[e[i].from], y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL N = 100050;

LL dt[N][3], pre[N];
LL n, m, L, s, t, head[N*2], cnt, dis[N*2];
struct edge{LL next,to,from; LL w;} e[N*6];
bool inq[N*2];
bool ok[1005][1005];

struct node
{
    LL dis;
	LL id;
    node(){}
    node(LL _,LL __){dis = _; id = __;}
    friend bool operator < (node a,node b)
    {
        return a.dis > b.dis;
    }
};

void link(LL u,LL v,LL w)
{
    ++ cnt;
    e[cnt].next = head[u];
    e[cnt].to = v;
    e[cnt].w = w;
    e[cnt].from = u;
    head[u] = cnt;
    ++ cnt;
    e[cnt].next = head[v];
    e[cnt].to = u;
    e[cnt].w = w;
    e[cnt].from = v;
    head[v] = cnt;
}

LL dij(LL u,LL v)
{
    priority_queue<node> q;
    node ahead, next;
    LL i;

    q.push(node(0,u));
    for(i = 0; i < n; ++ i) dis[i] = 1000000000000000000LL;
    dis[u] = 0; inq[u] = true;
    while(!q.empty())
    {
        ahead = q.top(); q.pop();
        inq[ahead.id] = false;
        for(i = head[ahead.id]; i ; i = e[i].next)
        {
            next.id = e[i].to;
            if(dis[next.id] > dis[ahead.id] + e[i].w)
            {
                dis[next.id] = dis[ahead.id] + e[i].w;
                next.dis = dis[next.id];
                if(!inq[next.id])
                {pre[next.id] = i; q.push(next), inq[next.id] = true;}
            }
        }
    }
    return dis[v];
}

int main()
{
    LL i, x, y, z, Qans;
    scanf("%I64d%I64d%I64d%I64d%I64d",&n,&m,&L,&s,&t);
    for(i = 1; i <= m; ++ i)
    {
        scanf("%I64d%I64d%I64d",&x,&y,&z);
        dt[i][0] = x; dt[i][1] = y; dt[i][2] = z;
        if(!z) ok[x][y] = ok[y][x] = true;
		if(z) link(x,y,z);
    }
    Qans = dij(s,t);
    if(Qans < L) {puts("NO"); return 0;}
    if(Qans == L)
    {
    	puts("YES");
    	for(i = 1; i <= m; ++ i)
    		if(dt[i][2] == 0) printf("%I64d %I64d 10000000000000000\n",dt[i][0],dt[i][1]);
    		else printf("%I64d %I64d %I64d\n",dt[i][0],dt[i][1],dt[i][2]);
    	return 0;
	}
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0) link(dt[i][0],dt[i][1],1);
	Qans = dij(s,t);
	if(Qans > L) {puts("NO"); return 0;}
	i = pre[t];
	while(e[i].w != 1 || !ok[e[i].from][e[i].to]) i = pre[e[i].from];
	x = i; y = 0;
	while(e[i].from != s) {y += (e[i].w == 1 && ok[e[i].from][e[i].to]); if((e[i].w == 1 && ok[e[i].from][e[i].to])) x = i; i = pre[e[i].from]; }
	y += (e[i].w == 1 && ok[e[i].from][e[i].to]);
	puts("YES");
	for(i = 1; i <= m; ++ i)
		if(dt[i][2] == 0 && ((dt[i][0] == e[x].from && dt[i][1] == e[x].to) || (dt[i][0] == e[x].to && dt[i][1] == e[x].from)))
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], L - Qans + 1);
		else
			printf("%I64d %I64d %I64d\n",dt[i][0], dt[i][1], dt[i][2] == 0?1:dt[i][2]);
    return 0;
}