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
using namespace std;
int n,m,s,t,l;
struct E {int x,y,c; bool mrk;} e[M];
int head[N],nxt[M<<1],to[M<<1],v[M<<1],lst=-1,ans=0,cnt=0,dist;
int path1[N],tmp[N],path2[N],dis[N];
bool used[N];
inline void adde(int x,int y,int c) {nxt[++lst]=head[x]; to[lst]=y; v[lst]=c; head[x]=lst; }
bool SPFA()
{
	queue<int> que; memset(dis,63,sizeof(dis));
	que.push(s); dis[s]=0; used[s]=1;
	while(!que.empty())
	{
		int p=que.front(); que.pop();
		for(int i=head[p]; i!=-1 ;i=nxt[i])
		{
			if(dis[to[i]]>dis[p]+v[i])
			{
			//puts("?");
			//printf("?%I64d %I64d %I64d?",i,to[i],v[i]);
				dis[to[i]]=dis[p]+v[i];
				path1[to[i]]=p;
				tmp[to[i]]=i;
				if(!used[to[i]])
				{
					used[to[i]]=1;
					que.push(to[i]);
				}
			}
		}
	}
	//
	if(dis[t]>l) return false;
	for(int i=0;i<n;i++)
		if(i!=s && v[tmp[i]]==0)
		{
			e[tmp[i]/2].mrk=1;
			cnt++;
		}
	dist=dis[t];
	if(cnt>l-dis[t]) return false;
	queue<int> q; memset(dis,63,sizeof(dis)); memset(used,0,sizeof(used));
	que.push(s); dis[s]=0; used[s]=1;
	while(!q.empty())
	{
		int p=q.front(); q.pop();
		for(int i=head[p]; i!=-1 ;i=nxt[i])
		{
			if(dis[to[i]]>dis[p]+v[i] && v[i]!=0)
			{
				dis[to[i]]=dis[p]+v[i];
				path2[to[i]]=p;
				if(!used[to[i]])
				{
					used[to[i]]=1;
					q.push(to[i]);
				}
			}
		}
	}//printf("%d",dis[t]);
	if(dis[t]<l) return false;
	return true;
}
main()
{
	memset(head,-1,sizeof(head));
	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",&e[i].x,&e[i].y,&e[i].c);
		adde(e[i].x,e[i].y,e[i].c); adde(e[i].y,e[i].x,e[i].c);
	}
	/*for(i=0;i<n;i++)
	{
		printf("%d: ",i);
		for(j=head[i];j!=-1;j=nxt[j])
			printf("%d %d?",to[j], v[j]);
		printf("\n");
	}*/
	if(!SPFA()) {puts("NO"); return 0;}
	puts("YES");
	//printf("%d",cnt);
	int add=l-dist-cnt+1;
	for(i=0;i<m;i++) if(e[i].mrk) {e[i].c=add;}
	for(i=0;i<m;i++)
		if(e[i].mrk && e[i].c==0)
		{ 
			e[i].c=1;
		}
		else if(!e[i].mrk && e[i].c==0)
		{//printf("%d",e[i].c);
			e[i].c=1000000000;
		}
	for(i=0;i<m;i++)
		printf("%I64d %I64d %I64d\n",e[i].x,e[i].y,e[i].c);
	return 0;
}