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

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

#include<cstdio>
#include<cstring>
#include<queue>
#include<iostream>
#define N 1010
#define M 10010
#define int long long
#define INF 1000000000000000000
using namespace std;
int n,m,s,t,l;
int head[N],nxt[M<<1],to[M<<1],anc[M<<1],v[M<<1],lst=-1;
int dis[N],pa[N],tmp[N],minn,pos;
bool used[N],flag[N];
inline void adde(int x,int y,int c) {nxt[++lst]=head[x]; anc[lst]=x; to[lst]=y; v[lst]=c; head[x]=lst; }
inline void clear() {memset(used,0,sizeof(used)); memset(pa,-1,sizeof(pa));for(int i=0;i<n;i++) dis[i]=INF; dis[s]=0; minn=INF; pos=-1;}
inline void print() {for(int i=0;i<2*m;i+=2) printf("%I64d %I64d %I64d\n",anc[i],to[i],(v[i]==0) ? INF : v[i]);}//0->INF
void dij()
{
	clear();
	for(int i=0;i<n;i++)
	{
		minn=INF;
		for(int j=0;j<n;j++) if(dis[j]<minn && !used[j]) {minn=dis[j]; pos=j;}
		used[pos]=1;
		for(int j=head[pos];j!=-1;j=nxt[j]) 
			if(dis[to[j]]>dis[pos]+v[j] && !used[to[j]] && v[j]!=0)
				dis[to[j]]=dis[pos]+v[j],pa[to[j]]=j,tmp[to[j]]=pos;
	}
}
main()
{
	memset(head,-1,sizeof(head));memset(v,-1,sizeof(v));
	int i,j,x,y,c;
	scanf("%I64d %I64d %I64d %I64d %I64d",&n,&m,&l,&s,&t);
	for(i=0;i<m;i++)
	{
		scanf("%I64d %I64d %I64d",&x,&y,&c);
		if(c==0) flag[lst+1]=flag[lst+2]=1;
		adde(x,y,c); adde(y,x,c);
	}
	dij();
	if(dis[t]<l) {puts("NO"); return 0;}
	if(dis[t]==l) {puts("YES"); print(); return 0;}
	for(i=0;i<2*m;i++) if(!v[i]) v[i]=1;
	dij();
	if(dis[t]>l) {puts("NO"); return 0;}
	while(dis[t]!=l)
	{
		for(j=t;j!=s;j=tmp[j]) if(flag[pa[j]]) {v[pa[j]]+=l-dis[t]; v[pa[j]^1]=v[pa[j]]; break;}
		dij();
	}
	puts("YES");
	print();
	return 0;
}